Connecting Machines
Jump to navigation
Jump to search
On Mac/WSL
- Check you have an Admitto account and collect your password from https://www.ch.cam.ac.uk/computing/admitto-service
- The bastion host barbican.ch.cam.ac.uk requires ssh keys and an MFA token to log in. Instructions can be found here: https://www.ch.cam.ac.uk/computing/network-bastion-host
- In the terminal run the command ssh -X crsid@barbican.ch.cam.ac.uk
- When prompted input your Admitto username (crsid) and password
- Once this has worked run the command ssh -X crsid@machinename in the terminal to log into a particular machine
Set up logging in without a password:
- Generate an ssh key by running the command ssh-keygen in the terminal, as described in detail in the section "Introduction to basic shell commands"
- Use cd ~/.ssh to navigate to the directory holding the keys, and copy the text from the file "id_rsa.pub" beginning with ssh-rsa. This is your public ssh key
- Log into the department barbican machine, and create / navigate to a directory called .ssh
- Use chmod 700 .ssh to set permissions for the directory
- Input vi authorized_keys to open up the vi text editor. Press i, then paste in your public ssh key. Press escape, then type :wq and press enter to write and quit the editor
- Log into the particular machine you want to ssh to, and repeat steps 3 to 5
- Exit back to your machine and navigate to the home directory
- Input vi .ssh/config to open the vi text editor. Press i, then paste in the following, with your crsid and machine name in the places given:
Host barbican
User crsid
Hostname barbican.ch.cam.ac.uk
ForwardAgent yes
ProxyCommand none
Host machinename
Hostname machinename
ProxyCommand ssh barbican -W %h:%p
User crsid
ForwardAgent yes
ServerAliveInterval 60
ServerAliveCountMax 10
Press escape, then input :wq followed by enter to exit the editor. You can now log straight into barbical with ssh barbican or straight into your machine with ssh machinename. The last two commands stop the ssh being killed if you are idle for too long. The ServerAliveInterval is how many seconds to ping a null packet, and the ServerAliveCountMax are how many consecutive times it needs to fail for the ssh to be killed.
Using VSCode Remote
Windows
- Find your wsl ssh config file as a Windows path, for example '\\wsl.localhost\Ubuntu\home\<name>\.ssh\config
- Make sure you have the 'Remote SSH' extension installed in VSCode
- In your config file, instead of using the layout above, change it to
Host barbican
User <crsid>
Hostname barbican.ch.cam.ac.uk
ForwardAgent yes
ProxyCommand none
Host <machinename>
Hostname <machinename>
ProxyJump barbican
User <crsid>
ServerAliveInterval 60
ServerAliveCountMax 10
(this has removed the ForwardAgent and ProxyCommand lines and replaced with ProxyJump instead)
- In VSCode, set your ssh config file manually to your path. Your wsl ssh folder can be copied into a Windows path (C:\Users\<user>\<blah>)if VSCode is not happy with the wsl path.
- At the bottom left, the green arrows is where you will be able to connect to remote machines. Click on it, and it should recognise all the hosts in your config file
- Select your host, and you will need to enter your password twice