ssh config

From Fluids Wiki
Revision as of 20:26, 2 August 2013 by Fluidslab (talk | contribs)
Jump to navigation Jump to search

You can use the ssh configuration file to save typing the full host name most of the time. For example, "ssh belize" is faster than "ssh belize.math.uwaterloo.ca".

The basics

Create the file ~/.ssh/config, and add the following:

   # MATH hosts
   Host belize thelon winisk kazan zambezi plata fe101 fe105 fe107 cpu105 cpu111 cpu113 cpu119 cpu121 cpu123 cpu125 cpu127
       HostName %h.math.uwaterloo.ca

   # SHARCNET hosts
   Host kraken orca requin saw angel dtn gulf hound lundun mako megamouth monk tope bramble brown goblin gulper guppy iqaluk prism redfin school wobbie
       HostName %h.sharcnet.ca

then change permissions on that config file to be only readable by your user:

   chmod 600 ~/.ssh/config

and sure that ~/.ssh has full access only to your user:

   chmod 700 ~/.ssh

Now you'll be able to ssh directly to all of those hosts by just using the main name.

SciNet

SciNet has a login node that you need to login to first before you can access the transfer/development nodes. You can shortcut this process with a few more lines in your ~/.ssh/config file. The following lines make sense for any machine outside of SciNet (your laptop, belize, etc).

  # SciNet
  Host scinet sci
      HostName login.scinet.utoronto.ca

  Host dm1 datamover1
      Hostname datamover1
      ProxyCommand ssh -q scinet -W %h:%p

  Host dm2 datamover2
      Hostname datamover2
      ProxyCommand ssh -q scinet -W %h:%p

  Host gpc*
      ProxyCommand ssh -q scinet -W %h:%p

For the ~/.ssh/config file on your SciNet account, you do not want to include the proxy commands. It only makes sense to include the aliases:

  # SciNet
  Host scinet sci
      HostName login.scinet.utoronto.ca

  Host dm1
      Hostname datamover1

  Host dm2
      Hostname datamover2

X Forwarding

If you want to automatically enable X forwarding, you can add

      ForwardX11 yes
      ForwardX11Trusted yes

to the hosts that you want to enable the X forwarding for. It's generally a Bad Idea to enable it for all hosts, so only enable it for the hosts that you trust and will be forwarding X from. If this is the MATH machines, then the snippet from the top becomes

  # MATH hosts
  Host belize thelon winisk kazan zambezi plata fe101 fe105 fe107 cpu105 cpu111 cpu113 cpu119 cpu121 cpu123 cpu125 cpu127
      HostName %h.math.uwaterloo.ca
      ForwardX11 yes
      ForwardX11Trusted yes

thelon / kazan / winisk

These hosts don't understand the %h shortcut used above. So you need to paste in the fully spelled out aliases for those systems:

# MATH hosts
Host belize belize.math
    HostName belize.math.uwaterloo.ca

Host thelon thelon.math
    HostName thelon.math.uwaterloo.ca

Host winisk winisk.math
    HostName winisk.math.uwaterloo.ca

Host kazan kazan.math
    HostName kazan.math.uwaterloo.ca

Host fe101 fe101.math
    HostName fe101.math.uwaterloo.ca

Host fe105 fe105.math
    HostName fe105.math.uwaterloo.ca

Host fe107 fe107.math
    HostName fe107.math.uwaterloo.ca

Host cpu105 cpu105.math
    HostName cpu105.math.uwaterloo.ca

Host cpu111 cpu111.math
    HostName cpu111.math.uwaterloo.ca

Host cpu113 cpu113.math
    HostName cpu113.math.uwaterloo.ca

Host cpu119 cpu119.math
    HostName cpu119.math.uwaterloo.ca

Host cpu121 cpu121.math
    HostName cpu121.math.uwaterloo.ca

Host cpu123 cpu123.math
    HostName cpu123.math.uwaterloo.ca

Host cpu125 cpu125.math
    HostName cpu125.math.uwaterloo.ca

Host cpu127 cpu127.math
    HostName cpu127.math.uwaterloo.ca

# SHARCNET hosts
Host kraken
    HostName kraken.sharcnet.ca

Host orca
    HostName orca.sharcnet.ca

Host requin
    HostName requin.sharcnet.ca

Host saw
    HostName saw.sharcnet.ca

Host angel
    HostName angel.sharcnet.ca

Host dtn
    HostName dtn.sharcnet.ca

Host gulf
    HostName gulf.sharcnet.ca

Host hound
    HostName hound.sharcnet.ca

Host lundun
    HostName lundun.sharcnet.ca

Host mako
    HostName mako.sharcnet.ca

Host megamouth
    HostName megamouth.sharcnet.ca

Host monk
    HostName monk.sharcnet.ca

Host tope
    HostName tope.sharcnet.ca

Host bramble
    HostName bramble.sharcnet.ca

Host brown
    HostName brown.sharcnet.ca

Host goblin
    HostName goblin.sharcnet.ca

Host gulper
    HostName gulper.sharcnet.ca

Host guppy
    HostName guppy.sharcnet.ca

Host iqaluk
    HostName iqaluk.sharcnet.ca

Host prism
    HostName prism.sharcnet.ca

Host redfin
    HostName redfin.sharcnet.ca

Host school
    HostName school.sharcnet.ca

Host wobbie
    HostName wobbie.sharcnet.ca