Host Aliases

To reduce typing with ssh/scp/sftp/rsync commands, you can create a file called ~/.ssh/config to provide an alias for a hostname, and configure that alias to use a particular username for that host. These aliases allow you to use short names in ssh and rsync command, e.g. ssh unity or rsync -r andromeda:/data/mylab/somedir/ ./somedir/. See the example below for what these blocks may look like for our research clusters.

Managing multiple ssh keys

If you use SSH with multiple systems, then you may want to or have reason to require more than one ssh key. With Putty and Puttygen, this is fairly easy to manage, as you will have several .ppk files that you can load into Putty Agent and then Putty (and other utilities such as CyberDuck) will pick the correct key for the connection. With command line ssh, you can configure different hosts to use different keys. See the example ~/.ssh/config below.

Note: Always make sure the keys in your ~/.ssh/ directory have the correct permissions. In macOS and Linux (including Windows Subsystem for Linux), you can use the command chmod 0600 ~/.ssh/id_unity, for example.

Example ~/.ssh/config

#Use only the configured key
IdentitiesOnly=yes
# Add keys to the agent as required on first connection
AddKeysToAgent=yes
# Forward the agent credentials, which allows ssh'ing to nodes your job is running on
ForwardAgent=yes

Host unity
Hostname=unity.uri.edu
User=username_uri_edu
IdentityFile=~/.ssh/id_unity

Host andromeda
Hostname=ssh3.hac.uri.edu
User=username
IdentityFile=~/.ssh/id_rsa