Project

General

Profile

Create SSH keys for Login » History » Revision 10

Revision 9 (Timo Eronen, 2016-05-04 08:23) → Revision 10/12 (Timo Eronen, 2016-05-04 08:28)

h1. Create SSH keys for Login 

 As an example we create keys for *titan* cluster. 

 h3. 1) Login to (your personal) 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. 

 h3. 2) 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. 

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

 <pre> 
 chmod 400 id_rsa_titan 
 </pre> 

 h3. 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.* 

 <pre> 
 scp id_rsa_titan.pub titan.utu.fi: 
 </pre> 

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

 <pre> 
 ssh titan.utu.fi 
 cd ~/.ssh/ 
 </pre> 

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

 *Option 6a*) 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 6b*) 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> 

 h3. 7) Logout from titan.utu.fi 

 h3. 8) Edit your local config file in your personal computer in directory *~/.ssh* ... 

 <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>