SSH config file
It is quite useful to have a .ssh/config
file, which may look like:
Host $HOSTALIAS
Hostname $HOST
User $USER
# from the outside we have to go through geniux
ProxyJump geniux.molgen.mpg.de
ForwardX11 yes
# for jupyter
LocalForward $PORT $HOST:$PORT
where you have to substitute the $X
expressions
$HOST with your preferred compute server, e.g. nyancat
$HOSTALIAS with a short name for $HOST, e.g. ny
$USER with your user name
$PORT with the port number used for jupyter, otherwise comment this line
For more advanced options check out: man ssh_config
tab-completion of hostnames
On the linux cluster the first 3 letters of most hostnames are unique. Therefore tab-completion works nicely after 3 letters only.
Put this code block in your .bashrc
:
HOST_NAMES=( $( cut -f1 -d' ' ~/.ssh/known_hosts |\
tr ',' '\n' |\
sort -u |\
grep -e '[[:alpha:]]')
$( awk '{print $1}' /etc/hostconfig |\
grep -v "^#" |\
grep -v "^$" |\
sort -u ) )
complete -o default -W "${HOST_NAMES[*]}" ssh