SSH configuration file
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:
[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
[name@yourLaptop ~] ssh narval
This also changes the behaviour of sftp
, scp
, and rsync
and you can now transfer files by typing for example
[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.