Project

General

Profile

Actions

Create SSH keys for Login

As an example we create keys for titan cluster.

1) Login to (your personal) computer from which you want to access the Cluster and change into directory ~/.ssh/

cd ~/.ssh/

If you don't have such directory, create it and change into it.

2) Create key pair using the following command.

DO NOT SETUP PASSPHRASE !!

ssh-keygen -f id_rsa_titan -t rsa

Now you have key pair:

  • id_rsa_titan is your private key. Keep it secret.
  • id_rsa_titan.pub is your public key.

3) Make sure the private key has the right protection:

chmod 400 id_rsa_titan

4) Send the public key (id_rsa_titan.pub) to the Cluster:

DO NOT SEND FILE id_rsa_titan WHICH IS YOUR PRIVATE KEY AND SHOULD BE KEPT SECRET.

scp id_rsa_titan.pub titan.utu.fi:

5) Login into titan.utu.fi and while logged change into directory ~/.ssh

ssh titan.utu.fi
cd ~/.ssh/

6) Depending on whether you already have file named authorized_keys continue with either Option 6a or Option 6b.

Option 6a) If you have file named authorized_keys add contents of id_rsa_titan.pub at the end of authorized_keys

cat ../id_rsa_titan.pub >> ./authorized_keys

Now you can get rid of file ../id_rsa_titan.pub

rm ../id_rsa_titan.pub

Option 6b) If you don't have file named authorized_keys rename id_rsa_titan.pub to authorized_keys and move it:

mv ../id_rsa_titan.pub ./authorized_keys

7) Logout from titan.utu.fi

8) Using your favorite text editor, edit your local config file in your personal computer in directory ~/.ssh

"text editor" config

... and add the following lines:

Host titan
    User YOUR_USERID
    HostName titan.utu.fi
    IdentityFile ~/.ssh/id_rsa_titan

Replace YOUR_USERID with your user id in titan.

You setup is done now and you should be able to login without giving the password:

ssh titan

Updated by Henrik Levämäki almost 8 years ago · 12 revisions