SSHTips

From SGEES Wiki
Jump to: navigation, search

Paswordless Login to Servers

Keep Connection Active

To save network resources ITS drops any not active connection by timeout (20 minutes). If you found this annoying, you might add the following lines to the top of your SSH configuration file (~/.ssh/config) :

 Host *
   ServerAliveInterval 100

Aliases

SSH config file can handle abbreviations and shortcuts for preferred hosts. For example:

Host 017
  HostName sgees017.geo.vuw.ac.nz
  User doejohn 

Instead of typing ssh doejohn@sgees017.geo.vuw.ac.nz you'll need only run ssh 017


Different Environment for Different Servers

You might find useful to set some environment variables depending on what server you've logged in. Just add following lines to the end of your ~/.bashrc (and edit them according to your needs):

if [ $HOSTNAME == "co501pc02.geo.vuw.ac.nz" ]; then
    # We're logged in locally to our desktop
    export PATH=$HOME/bin:$PATH
    . ~/.bash_completion
elif [ $HOSTNAME == "sgees017.geo.vuw.ac.nz" ]; then
    echo "We are on SGEES017"
    export GMT_HOME=/usr/local/gmt
else
    echo "Logged in to: $HOSTNAME"
fi

If connection is not reliable