This process involves generating an RSA key pair that will be used to securely access the student environment. The public key will be stored on the student environment, with the private key kept on our local machine.
We also create an SSH configuration, which: 1. specifies that our private key should be used when connecting to the student environment, and 2. defines a customizable alias for the host name.
- Open a terminal.
- Run the following command:
ssh-keygen
- At the prompt, enter the text below, substituting your Mac username in for
username
:
/Users/username/.ssh/cs_key
- At the prompt, enter the text below, substituting your Mac username in for
username
:
/home/username/.ssh/cs_key
- At the prompt, enter the text below, substituting your Mac username in for
username
:
/c/Users/username/.ssh/cs_key
- Press
Enter
at the remaining prompts.
- Create or edit the SSH configuration file at
~/.ssh/config
. Add an entry containing the following:
Host cs
HostName linux.student.cs.uwaterloo.ca
User watiam_id
IdentityFile ~/.ssh/cs_key
Notes:
- Replace
watiam_id
with your own ID. - Feel free to change the value for
Host
– this value is what you will type when using thessh
command in the future.
- Print the contents of your public key file with:
cat ~/.ssh/cs_key.pub
- Copy the output to the clipboard.
ssh
into the student environment with:
ssh cs
(replacing cs
with your Host
value, if different)
- Create or edit
~/.ssh/authorized_keys
:- You will need to create the
.ssh
directory if it does not exist.
- You will need to create the
- Paste the content from your clipboard on its own single line in the file. If the file is not empty, add a line at the end of the file. It should look something like this:
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDWSwzGvsYHCAZ2g6xccbGBdNb6wBbghd7kspx6eTPt4RSlLPEewBg3qogyj3I+DSa2M+Mql8xG4A6TLj7mOeIrS6BDcX5NEi3mStN5Bt+jj1SqRJYceD93a7RjPaaaaakjakdshfklhasldkhflkasdjhfaksjldhfhXjIm7RIFjivq56TpK8HXd/YXD29IY4o4MPr6rXJcMKws5fnl3kywYRwv7Hg9mPKdHnKm9En2PXtq7BXVlNz+lQt1cQ9GpKHiPt69GlzervXGSFt54eaddTrEbzzesoZ4OtDbnwWEh3Pp95FvZFdejLbIakpUTJnPCWU7EAGCV4Me1thDZQ5 [email protected]
- The content may be split over 2 lines by default. A good way to check that it is on one line is with
wc
, or by displaying line numbers invi
by typing:set number
while in Normal mode.
- Save the file.
- If you just created the
authorized_keys
file, fix the permissions with the following:
chmod 600 ~/.ssh/authorized_keys
You should now be able to ssh
into the student environment without being asked for a password.