I am using the cluster GRAHAM for our simulation, and it uses SSH (Secure Shell) to connect to the remote servers. It is found annoying to type the password everytime you try to log in or copy files from the server. Herewith several simple commands, we could domake the password-less connection (for MacOS only).

  1. cd ~/.ssh/, enter the folder where the ssh keys are kept.
  2. ssh-keygen -t rsa, create a new ssh key pair. You would be asked to Enter file in which to save the key: and I use graham here.
  3. ssh-add -K graham, add the ssh private key to the ssh-agent to store the passphrase the keychain.
  4. cat graham.pub >> authorized_keys, write the public key into the file authorized_keys.
  5. ssh-copy-id -i graham.pub USER@graham.computecanada.ca, ssh-copy-id is to use locally available keys to authorize logins on a remote machine. The authorized_keys is copied to the cluster.
  6. Add the following lines to ~/.ssh/config to avoid ssh-add everytime after restart.
    1
    2
    3
    4
    5
    6
    7
    Host graham.computecanada.ca
    HostName graham.computecanada.ca
    User Username
    PreferredAuthentications publickey
    IdentityFile ~/.ssh/graham
    UseKeychain yes
    AddKeysToAgent yes

Done!

PS: add alias graham='ssh -y USER@graham.comoputecanada.ca' into ~./bash_profile for convenience