Lab01 - Environment Setup
Due:
Mon, Jan 31, 2022 at 11:59 PM
to Github Classroom Assignment
Login to stargate
- Choose a terminal app for your laptop. There are many options but here are a few:
- Windows: Windows Terminal, PuTTY, Windows Subsystem for Linux (which is what I use)
- macOS: Apple’s built-in terminal.app, iTerm2 (which is what I use)
- Use your terminal app to
ssh
to stargate$ ssh username@stargate.cs.usfca.edu
replacing username with your USF login ID. The password is your USF CWID. You should see:
The authenticity of host 'remote-host' can't be established... Are you sure you want to continue connecting? (yes/no) yes username@stargate $
Type
^D
(CTRL-d) to exit thessh
session.
Create an ssh key pair (if you don’t already have one)
- Create an ssh key pair using this command in your terminal
me@mylaptop:~ $ ssh-keygen -t ed25519 -C "your_email@example.com"
- You will be asked to provide a passphrase which is used to encrypt your private key. Do not forget this passphrase.
-
me@mylaptop:~ $ cd ~/.ssh me@mylaptop:~/.ssh $ ls id_ed25519 id_ed25519.pub
- These are just text files and you can
cat
them to see their contents id_ed25519
is your private key. You should never upload that file to any servers, or give it to anyone.id_ed25519.pub
is your public key. This file can be uploaded to stargate and Github.com
- These are just text files and you can
- Configure stargate so your private key can be used to authenticate you on github.com
username@stargate:~/.ssh $ cat >config Host * ForwardAgent yes ^D
Set up Github with your public key
- Copy your public key to your laptop’s clipboard:
- Windows Terminal:
$ type id_ed25519.pub | clip
- WSL:
$ cat id_ed25519.pub | xclip
- macOS:
$ cat id_ed25519.pub | pbcopy
- Windows Terminal:
- Create an account on github.com if you don’t already have one.
- When logged into github.com go to Profile > Settings > SSH and GPG Keys and paste the contents of your public key
- Test your ssh access to github.com from your terminal app
me@mylaptop:~ $ ssh git@github.com Hi username! You've successfully authenticated, but GitHub does not provide shell access. Connection to github.com closed.
Set up ~/.ssh/config on your laptop
- From your terminal app (you can use any editor, not just
nano
)me@mylaptop:~ $ cd .ssh me@mylaptop:~ $ nano config
make your config file look like the snippet below. Notes:
UseKeychain
is macOS-only so Windows users can omit it- Remember to replace
your_usf_login
with your USF login (e.g. phpeterson)Host github.com HostName github.com AddKeysToAgent yes UseKeychain yes IdentityFile ~/.ssh/id_ed25519 Host stargate.cs.usfca.edu ForwardAgent yes User your_usf_login AddKeysToAgent yes IdentityFile ~/.ssh/id_ed25519
Copy your public key to stargate
- From your terminal app
me@mylaptop:~/.ssh $ ssh-copy-id username@stargate.cs.usfca.edu
- Test your ssh access to stargate
me@mylaptop:~/.ssh $ ssh username@stargate.cs.usfca.edu ... username@stargate:~ $
- Set up ssh forwarding from stargate to your laptop
username@stargate:~ $ cd ~/.ssh username@stargate:~/.ssh $ cat >config Host * ForwardAgent yes ^D
Choose one of the lab systems to work on
- Do not do class work on the stargate host. SSH to one of the lab hosts listed by
rusers
username@stargate:~ $ rusers ... username@stargate:~ $ ssh vlab01 username@vlab01:~ $
Finally, some code
- Clone the assignment repository (“repo”) into your home directory
username@vlab01:~ $ git clone git@github.com:/cs221-s22/lab01-yourgithubid username@vlab01:~ cd lab01-yourgithubid
- Compile the program
username@vlab01:lab01-yourgithubid $ gcc -o hello hello.c
- Run the program
username@vlab01:lab01-yourgithubid $ ./hello hello world
- Edit
hello.c
and change"hello world\n"
to"hello cs221\n"
in lower case exactly as shown - Save the file and recompile it
- Commit your changes to the local repo on the lab machine
username@vlab01:lab01-yourgithubid $ git commit -m"change world to cs221" hello.c
- Push your changes from the local repo to the remote repo on github.com
username@vlab01:lab01-yourgithubid $ git push
^D
to log out of the lab host, and again to log out ofstargate