Skip to content

Instantly share code, notes, and snippets.

@sbamin
Created May 5, 2023 17:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sbamin/e8fbde14f4c7626efcf14fcfafb42c05 to your computer and use it in GitHub Desktop.
Save sbamin/e8fbde14f4c7626efcf14fcfafb42c05 to your computer and use it in GitHub Desktop.
Persistent SSH connection via SSH ControlMaster.
## add following to mac ~/.ssh/config file after required edits
## then do ssh mcclearybg to start background session, typically
## once per day. This will require duo push
## then you can start additional ssh by ssh mccleary (note: no suffix bg)
## More at https://docs.ycrc.yale.edu/clusters-at-yale/access/advanced-config/ and
## https://www.anchor.com.au/blog/2010/02/ssh-controlmaster-the-good-the-bad-the-ugly/
################## Yale ##################
# Uncomment the ForwardX11 options line to enable X11 Forwarding by default (no -Y necessary)
# On a Mac you still need xquartz installed
## EditMe:
# for ControlMaster: make ControlPath dir, e.g., mkdir -p ~/.ssh/tmp
# replace User: foo with your netid
Host *.hpc.yale.edu farnam grace milgram ruddle
User foo
ServerAliveInterval 40
StrictHostKeyChecking no
Compression yes
# ForwardX11 yes
Host farnam grace milgram ruddle
HostName %h.hpc.yale.edu
Host *.ycrc.yale.edu mccleary
User foo
ControlMaster auto
ControlPath ~/.ssh/tmp/%h_%p_%r.sock
ControlPersist 10s
ServerAliveInterval 40
StrictHostKeyChecking yes
Compression yes
# ForwardX11 yes
Host mccleary
HostName %h.ycrc.yale.edu
Host mcclearybg
HostName mccleary.ycrc.yale.edu
User foo
ControlMaster auto
ControlPath ~/.ssh/tmp/%h_%p_%r.sock
ControlPersist 10s
ServerAliveInterval 40
StrictHostKeyChecking yes
Compression yes
ExitOnForwardFailure yes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment