Created
February 19, 2016 16:44
-
-
Save mcocdawc/93fbb7f8de3c09ab9517 to your computer and use it in GitHub Desktop.
No retyping of passwords for computerclusters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ControlMaster auto | |
ControlPath ~/.ssh/control:%h:%p:%r | |
Host server1 | |
User username_on_server1 | |
HostName server1.com | |
Host server2 | |
User username_on_server2 | |
HostName server2.com |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Opens ssh sessions to be picked up by ControlMaster in ~/.ssh/config during the day | |
# -f forks to the background | |
# -N no commands to be executed on remote computer | |
# -o Specify ssh options | |
for computer in server1 server2; do | |
printf "\n \n $computer \n \n" | |
ssh -f $computer -N -o 'ServerAliveInterval 300' -o 'ServerAliveCountMax 100' | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is a minimal example of how to set up your ssh to not retype your passwords when often sshing to computer clusters from Unix.
Speak with the administrators of the remote servers if they allow this:
config
to~/.ssh/config/
silent_ssh
to a directory which is inPATH
and make it executable.server1
,username_on_server1
... with the actual names.If you now execute
silent_ssh
it creates background processes of ssh connections to the remote servers.Every time you reconnect to the server the
ControlMaster
will reuse the existing ssh connection.This includes other
ssh
based services likescp
,sftp
orrsync
.Because of the options
-o 'ServerAliveInterval 300' -o 'ServerAliveCountMax 100'
you have to reexecutesilent_ssh
approximately every 8 hours.