Create SSH keys for Login » History » Revision 8
Revision 7 (Timo Eronen, 2016-05-04 08:21) → Revision 8/12 (Timo Eronen, 2016-05-04 08:23)
h1. Create SSH keys for Login
As an example we create keys for *titan* cluster.
h2. Login to the computer from which you want to access the Cluster and change into directory *~/.ssh/*
<pre>
cd ~/.ssh/
</pre>
If you don't have such directory, create it and change into it.
Create key pair using the following command.
*DO NOT SETUP PASSPHRASE !!*
<pre>
ssh-keygen -f id_rsa_titan -t rsa
</pre>
Now you have key pair:
* *id_rsa_titan* is your private key. *Keep it secret*.
* *id_rsa_titan.pub* is your public key.
Make sure the private key has the right protection:
<pre>
chmod 400 id_rsa_titan
</pre>
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.*
<pre>
scp id_rsa_titan.pub titan.utu.fi:
</pre>
Login into titan.utu.fi and while logged change into directory *~/.ssh*
<pre>
ssh titan.utu.fi
cd ~/.ssh/
</pre>
Depending on whether you already have file named *authorized_keys* continue with either *Option A* or *Option B*.
*Option A*) If you have file named *authorized_keys* add contents of id_rsa_titan.pub at the end of *authorized_keys*
<pre>
cat ../id_rsa_titan.pub >> ./authorized_keys
</pre>
Now you can get rid of file ../id_rsa_titan.pub
<pre>
rm ../id_rsa_titan.pub
</pre>
*Option B*) If you don't have file named *authorized_keys* rename id_rsa_titan.pub to *authorized_keys* and move it:
<pre>
mv ../id_rsa_titan.pub ./authorized_keys
</pre>
Logout from titan.utu.fi
Edit your local config file ...
<pre>
emacs config
</pre>
... and add the following lines:
<pre>
Host titan
User YOUR_USERID
HostName titan.utu.fi
IdentityFile ~/.ssh/id_rsa_titan
</pre>
Replace YOUR_USERID with your user id in titan.
You setup is done now and you should be able to login:
<pre>
ssh titan
</pre>