Project

General

Profile

Create SSH keys for Login » History » Version 4

Timo Eronen, 2016-05-04 08:03

1 1 Timo Eronen
h1. Create SSH keys for Login
2
3
As an example we create keys for *titan* cluster.
4
5 3 Timo Eronen
Login to the computer from which you want to access the Cluster and change into directory *~/.ssh/*
6 1 Timo Eronen
7
<pre>
8 4 Timo Eronen
ssh titan.utu.fi
9 1 Timo Eronen
cd ~/.ssh/
10
</pre>
11
12
If you don't have such directory, create it and change into it.
13
14
Create key pair using the following command.
15
16
*DO NOT SETUP PASSPHRASE !!*
17
18
<pre>
19
ssh-keygen -f id_rsa_titan -t rsa
20
</pre>
21
22 2 Timo Eronen
Now you have key pair:
23 1 Timo Eronen
24
* *id_rsa_titan* is your private key. *Keep it secret*.
25
* *id_rsa_titan.pub* is your public key.
26 2 Timo Eronen
27
Make sure the private key has the right protection:
28
29
<pre>
30
chmod 400 id_rsa_titan
31
</pre>
32
33 1 Timo Eronen
34
Send the public key (id_rsa_titan.pub) to the Cluster:
35
36
*DO NOT SEND FILE id_rsa_titan WHICH IS YOUR PRIVATE KEY AND SHOULD BE KEPT SECRET.*
37
38
<pre>
39
scp id_rsa_titan.pub titan.utu.fi:
40
</pre>
41
42
Login into titan.utu.fi and while logged change into directory *~/.ssh*
43
44
<pre>
45
cd ~/.ssh/
46
</pre>
47
48
a) If you have file named *authorized_keys* add contents of id_rsa_titan.pub at the end of *authorized_keys*
49
50
<pre>
51
cat ../id_rsa_titan.pub >> ./authorized_keys
52
</pre>
53
54
b) If you don't have file named *authorized_keys* rename id_rsa_titan.pub to *authorized_keys* and move it:
55
56
<pre>
57
mv ../id_rsa_titan.pub ./authorized_keys
58
</pre>
59
60
Logout from titan.utu.fi
61
62
Edit your local config file ...
63
64
<pre>
65
emacs config
66
</pre>
67
68
... and add the following lines:
69
70
<pre>
71
Host titan
72
    User YOUR_USERID
73
    HostName titan.utu.fi
74
    IdentityFile ~/.ssh/id_rsa_titan
75
</pre>
76
77
Replace YOUR_USERID with your user id in titan.
78
79
You setup is done now and you should be able to login:
80
81
<pre>
82
ssh titan
83
</pre>