Connecting to OSC with SSH in a terminal
Optional self-study content for week 9
This page will show you how you can connect a terminal on your local computer to OSC.
1 Basic SSH connection in a terminal
To connect to OSC or other remote computers without using a web portal like OnDemand, you can use SSH. You can do so via the ssh
command, which works in Windows and Unix-based (Max/Linux) terminals alike.
On your own computer, open a terminal application.
- On a Mac, you should have an app called “Terminal” and potentially other options like “iTerm”: any of these fill work
- On Windows 11+, this should be called the “Windows Terminal”
Type the command
ssh <user>@<host>
, replacing:<user>
with your OSC username<host>
with the name of the computer/cluster you want to connect to:pitzer.osc.edu
to connect to the Pitzer clustercardinal.osc.edu
to connect to the Cardinal cluster
For example, if I (username
jelmer
) wanted to log in to the Pitzer cluster, I would use:ssh jelmer@pitzer.osc.edu
The authenticity of host 'pitzer.osc.edu' can't be established. RSA key fingerprint is 2a:b6:f6:8d:9d:c2:f8:2b:8c:c5:03:06:a0:f8:59:12. Are you sure you want to continue connecting (yes/no)?
If this is the first time you are connecting to Pitzer via SSH, you’ll encounter a message similar to the one above. While the phrase “The authenticity of host ‘pitzer.osc.edu’ can’t be established.” sounds ominous, you will always get this warning when you attempt to connect to a remote computer for the first time, and you should type
yes
to proceed (you then won’t see this message again).Assuming that you did the no-password setup in week 9’s ungraded assignment, you should not be prompted for your password. (If you are asked for your password, then type it followed by Enter, and keep in mind that when you do so, no characters or even *s will appear on the screen!)
Your shell will now connect to OSC, and you should see some welcome messages and the familiar file quota listing – and your prompt should indicate that you’re at OSC, e.g.:
[jelmer@pitzer-login04 ~]$
2 Custom names for your SSH connections
2.1 Set up custom names
You can set up alternative names (“aliases”) for your SSH connections, such as shortening jelmer@pitzer.osc.edu
to jp
. This can be convenient when you use SSH a lot, especially when transferring files to and from OSC with SSH-based commands like scp
and rsync
(see this optional self-study page).
These two steps should both be done on your local machine:
Create a file called
~/.ssh/config
:touch ~/.ssh/config
Open the file in a text editor and add your alias(es) in the following format:
Host <arbitrary-alias-name> HostName <remote-address> User <username>
For instance, my file contains the following so as to connect to Pizer with
jp
and to Cardinal withjc
:Host jp HostName pitzer.osc.edu User jelmer Host jc HostName cardinal.osc.edu User jelmer
2.2 Connecting from now on
From now on, you just need to use your alias to log in:
ssh jp
And these shortcuts also work with remote transfer commands like scp
and rsync
! For example:
rsync ~/scripts op:/fs/scratch/PAS2880