SSH configuration file

From Alliance Doc
Revision as of 14:43, 11 May 2023 by Alicedb (talk | contribs) (Created page with "<translate> ''Parent page: SSH'' On Linux and macOS you can modify your local SSH configuration file to change the default behaviour of <code>ssh</code> and simplify the login procedure. For example, if you want to login to <code>narval.computecanada.ca</code> as <code>username</code> using a SSH key with both agent and X11 forwarding enabled you need to use the following command: {{Command|prompt=[name@yourLaptop ~]|ssh -A -Y -i ~/.ssh/y...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Parent page: SSH

On Linux and macOS you can modify your local SSH configuration file to change the default behaviour of ssh and simplify the login procedure. For example, if you want to login to narval.computecanada.ca as username using a SSH key with both agent and X11 forwarding enabled you need to use the following command:

Question.png
[name@yourLaptop ~] ssh -A -Y -i ~/.ssh/your_private_key username@narval.computecanada.ca

To avoid having to type this command each time you want to connect to Narval, add the following to ~/.ssh/config on your local machine:

 Host narval
   User username
   HostName narval.computecanada.ca
   IdentityFile ~/.ssh/your_private_key
   ForwardX11 yes
   ForwardX11Trusted yes
   ForwardAgent yes

You can now log into Narval by typing

Question.png
[name@yourLaptop ~] ssh narval

This also changes the behaviour of sftp, scp, and rsync and you can now transfer files by typing for example

Question.png
[name@yourLaptop ~] scp local_file narval:work/

If you frequently log into different clusters, modify the above Host block as follows instead of adding individual entries for each cluster separately:

 Host narval beluga graham cedar
   [...]
   HostName %h.computecanada.ca
   [...]

Note that you need to install your public SSH key on each cluster separately or use CCDB.