Project

General

Profile

Create SSH keys for Login » History » Version 5

Timo Eronen, 2016-05-04 08:04

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
cd ~/.ssh/
9
</pre>
10
11
If you don't have such directory, create it and change into it.
12
13
Create key pair using the following command.
14
15
*DO NOT SETUP PASSPHRASE !!*
16
17
<pre>
18
ssh-keygen -f id_rsa_titan -t rsa
19
</pre>
20
21 2 Timo Eronen
Now you have key pair:
22 1 Timo Eronen
23
* *id_rsa_titan* is your private key. *Keep it secret*.
24
* *id_rsa_titan.pub* is your public key.
25 2 Timo Eronen
26
Make sure the private key has the right protection:
27
28
<pre>
29
chmod 400 id_rsa_titan
30
</pre>
31
32 1 Timo Eronen
33
Send the public key (id_rsa_titan.pub) to the Cluster:
34
35
*DO NOT SEND FILE id_rsa_titan WHICH IS YOUR PRIVATE KEY AND SHOULD BE KEPT SECRET.*
36
37
<pre>
38
scp id_rsa_titan.pub titan.utu.fi:
39
</pre>
40
41
Login into titan.utu.fi and while logged change into directory *~/.ssh*
42
43
<pre>
44 5 Timo Eronen
ssh titan.utu.fi
45 1 Timo Eronen
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>