ssh config: Difference between revisions

From Fluids Wiki
Jump to navigation Jump to search
No edit summary
Line 27: Line 27:


Now you'll be able to ssh directly to all of those hosts by just using the main name.
Now you'll be able to ssh directly to all of those hosts by just using the main name.
== X Forwarding ==
If you want to automatically enable X forwarding, you can add
<syntaxhighlight lang="text" enclose="div">
      ForwardX11 yes
      ForwardX11Trusted yes
</syntaxhighlight>
to the hosts that you want to enable the X forwarding for. It's generally a [https://padraic2112.wordpress.com/2007/07/09/bad-security-201-remote-x-sessions-over-ssh/ 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
<syntaxhighlight lang="text" enclose="div">
  # MATH hosts
  Host belize thelon winisk kazan zambezi plata
      HostName %h.math.uwaterloo.ca
      ForwardX11 yes
      ForwardX11Trusted yes
</syntaxhighlight>


== SciNet ==
== SciNet ==
Line 50: Line 66:
</syntaxhighlight>
</syntaxhighlight>


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:
Here X is only forwarded from the gpc development nodes, and not from the datamover nodes. 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 here:


<syntaxhighlight lang="text" enclose="div">
<syntaxhighlight lang="text" enclose="div">
Line 62: Line 78:
   Host dm2
   Host dm2
       Hostname datamover2
       Hostname datamover2
</syntaxhighlight>
== X Forwarding ==
If you want to automatically enable X forwarding, you can add
<syntaxhighlight lang="text" enclose="div">
      ForwardX11 yes
      ForwardX11Trusted yes
</syntaxhighlight>
to the hosts that you want to enable the X forwarding for. It's generally a [https://padraic2112.wordpress.com/2007/07/09/bad-security-201-remote-x-sessions-over-ssh/ 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
<syntaxhighlight lang="text" enclose="div">
  # MATH hosts
  Host belize thelon winisk kazan zambezi plata
      HostName %h.math.uwaterloo.ca
      ForwardX11 yes
      ForwardX11Trusted yes
</syntaxhighlight>
</syntaxhighlight>



Revision as of 08:56, 3 August 2013

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
       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.

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
      HostName %h.math.uwaterloo.ca
      ForwardX11 yes
      ForwardX11Trusted yes

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 -Y scinet -W %h:%p
      ForwardX11 yes
      ForwardX11Trusted yes

Here X is only forwarded from the gpc development nodes, and not from the datamover nodes. 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 here:

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

  Host dm1
      Hostname datamover1

  Host dm2
      Hostname datamover2

Older SSH clients

If you're running an older SSH client, it won't understand the %h shortcut used above. In that case, you'll need to use 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

# 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