Creating and using SSH keys

Keys are more convenient (and also more secure if you additionaly disable password authentication) than passwords to access the CISM machines.

Assuming you do not have already an SSH key pair, the first step is to generate one.

Step one: Generate the SSH key pair

On your Linux or MacOs computer, issue the following command:

ssh-keygen -t rsa

You will be asked where to store the key, and to choose a passphrase. You can leave those options blank and just hit the Enter key. Make sure you do not overwrite any pre-existing key! As for the passphrase, it is best to choose one and then use an SSH agent and key ring as explained in the CÉCI website.

The above command hase created two files in your ~/.ssh/ directory:

  • id_rsa; and

The former is your private key, which you must not share, and the latter is the corresponding public key, that will be copied to the servers you want to connect to.

Step two: Copy the key to the remote server

The public key should be copied to the ~/.ssh/authorized_keys file on the remote server. That can be done with

$ ssh-copy-id <my_cism_login>@<machine_name>

Make sure to replace the parts in <my_cism_login> with your actual login and <machine_name> with the name of the computer you want to connect to. You will be asked your password, and upon success, you will then be able to connect from your laptop to that server without entering your password.