SSH

Table of contents

  1. Connecting
    1. Shortening the command with an SSH configuration file
    2. Logging in with an SSH key
  2. What to run on the head node
  3. Keeping work running after you disconnect

SSH (Secure Shell) connects you to a text-based shell on Ada’s head node. If this is your first time working with the shell, Software Carpentry offers a helpful introduction.

Ada is only accessible on campus or when connected to the VPN.

Connecting

macOS and recent versions of Windows include an SSH client. On macOS open the Terminal application; on Windows open PowerShell or the Command Prompt. Then run (replacing username with your Middlebury username):

ssh username@ada.middlebury.edu

The first time you connect, you may be asked to confirm the server’s fingerprint; type “yes” and press enter. Enter your Middlebury password when prompted. No characters are shown as you type your password, but it is being received.

To disconnect, run exit.

Shortening the command with an SSH configuration file

To connect with just ssh ada, add the following to the file ~/.ssh/config on your personal computer (create the file if it doesn’t exist), replacing username with your Middlebury username:

Host ada
    HostName ada.middlebury.edu
    User username

The shortcut also works with other SSH-based tools, e.g., scp my_file ada:/storage/username.

Logging in with an SSH key

An SSH key lets you log in without typing your Middlebury password each time. A key has two parts: a private key that stays on your computer, and a public key that you copy to Ada. Run these commands on your personal computer.

  1. Create a key (if you don’t already have one in ~/.ssh). Press enter to accept the default file location, and choose a passphrase to protect the key:

    ssh-keygen -t ed25519
    
  2. Copy the public key to Ada (you will be asked for your Middlebury password one last time). On macOS or Linux:

    ssh-copy-id username@ada.middlebury.edu
    

    On Windows (PowerShell), which doesn’t include ssh-copy-id:

    type $env:USERPROFILE\.ssh\id_ed25519.pub | ssh username@ada.middlebury.edu "mkdir -p ~/.ssh && chmod 700 ~/.ssh && cat >> ~/.ssh/authorized_keys && chmod 600 ~/.ssh/authorized_keys"
    
  3. Connect with ssh username@ada.middlebury.edu (or ssh ada). You will be asked for the key’s passphrase instead of your password. On macOS, add UseKeychain yes and AddKeysToAgent yes to the Host ada entry in ~/.ssh/config so you only enter the passphrase once.

Never share your private key (the file without .pub).

What to run on the head node

When you connect with SSH you are on the head node, which is shared by everyone. Use it to edit files, manage data, install software and submit jobs. Do not run computationally intensive work on the head node. Instead, submit a batch job or start an interactive job to get a shell on a compute node.

Keeping work running after you disconnect

If your connection drops, any command running in that SSH session is stopped. SLURM jobs are not affected. For long-running work on the head node (e.g., a large file transfer), use tmux, which keeps a session running on Ada after you disconnect:

Action Command
Start a new session named “work” tmux new -s work
Detach (leave it running) Press Ctrl-b, then d
Reattach after reconnecting tmux attach -t work
List your sessions tmux ls