Reusing your SSH login

Each fresh SSH connection to the cluster goes through password and Duo, which gets old fast when you have several terminal windows open. SSH connection multiplexing fixes this — after the first login, subsequent connections share that authenticated session and skip the prompts.

One-time setup

Add this block to ~/.ssh/config on your local workstation (not on the cluster):

Host hpc
    Hostname login.hpc.caltech.edu
    User yourusername
    ServerAliveInterval 60
    ControlMaster auto
    ControlPath ~/.ssh/sockets/%r@%h:%p
    ControlPersist 10m

Then create the sockets directory and tighten the config file’s permissions:

mkdir -p ~/.ssh/sockets
chmod 600 ~/.ssh/config

Connecting

ssh hpc

The first connection prompts for your access.caltech password and a Duo push. Every additional ssh hpc within ten minutes reuses that authenticated channel — no password, no Duo prompt, and the new shell opens roughly instantly.

Behind the scenes, SSH multiplexing keeps a single persistent control connection alive through the socket at ~/.ssh/sockets/. New SSH sessions to the same host attach to that connection rather than opening a new one. The ControlPersist 10m directive is what keeps the connection alive after you close your first terminal — without it, the socket dies on exit and the next session has to authenticate from scratch.

Troubleshooting

Still being prompted for a password. Make sure the config file lives on your local machine (not on the cluster), the permissions are right (chmod 600 ~/.ssh/config), and you’re using ssh hpc rather than the full hostname. The full hostname bypasses the alias and starts a fresh session each time.

“Control socket already exists” error. A previous multiplex session didn’t clean up. Remove the stale socket and reconnect:

rm ~/.ssh/sockets/yourusername@login.hpc.caltech.edu:22

See also