This gives basic examples of ssh use from the command line (also known as the terminal, cmd) on Linux, MacOS, and Windows 10 machines. For serious ssh use on Windows we recommend installing MobaXterm instead.
ssh
ssh ID@computer.domain e.g. ssh mr349@barbican.ch.cam.ac.uk man ssh
Connecting directly to a workstation via the bastion host with ProxyCommand
Ensure you have the following blocks in your ~/.ssh/config, replacing WORKSTATION and CRSID as appropriate.
Host WORKSTATION User CRSID ProxyCommand ssh CRSID@barbican.ch.cam.ac.uk -W WORKSTATIONch.private.cam.ac.uk:22
If you use a non-standard filename for your ssh key, you need to instruct your ssh client to use that for both the connection to the bastion host (barbican) and the subsequent connection to your workstation as follows (now also replacing PRIVATE_KEY_FILENAME).
Host barbican.ch.cam.ac.uk IdentityFile ~/.ssh/PRIVATE_KEY_FILENAME User CRSID Host WORKSTATION IdentityFile ~/.ssh/PRIVATE_KEY_FILENAME IdentitiesOnly yes User CRSID HostName WORKSTATION.ch.private.cam.ac.uk ProxyCommand ssh CRSID@barbican.ch.cam.ac.uk -W WORKSTATION.ch.private.cam.ac.uk:22
Then, you can simply ssh WORKSTATION
to connect, assuming there are no blocks in your ~/.ssh/config that would override any of the above.
scp
To copy files from the computer you are sitting at (local1) to a remote computer (server1):
scp ./file ID@server1:/home/ID/file e.g. mr@chm:~> scp womble.txt mr349@barbican.ch.cam.ac.uk:~ or: mr@chm:~> scp womble.txt mr349@barbican.ch.cam.ac.uk:~/womble.txt
To copy files from a remote computer (server1) to the computer you are sitting at (local1):
scp ID@server1:/home/ID/file ./file e.g. mr@chm:~> scp mr349@barbican.ch.cam.ac.uk:~/womble.txt . or: mr@chm:~> scp mr349@barbican.ch.cam.ac.uk:~/womble.txt ./womble.txt man scp
If you need to do scp from outside Chemistry's firewall to inside it, or vice versa, see https://www.ch.cam.ac.uk/computing/scp-over-ssh-tunnel
sftp
To sftp to a computer called server1.ch.cam.ac.uk
sftp ID@server1.ch.cam.ac.uk > for more info: > help man sftp
X11 forwarding
ssh -X ID@computer.domain e.g. ssh -X mr349@barbican.ch.cam.ac.uk
The -X is the option for X11 forwarding and if you are using a medium/slow connection then you might want compression: -C.