Create SSH keys for Login » History » Version 3
Timo Eronen, 2016-05-04 08:02
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 | cd ~/.ssh/ |
||
45 | </pre> |
||
46 | |||
47 | a) If you have file named *authorized_keys* add contents of id_rsa_titan.pub at the end of *authorized_keys* |
||
48 | |||
49 | <pre> |
||
50 | cat ../id_rsa_titan.pub >> ./authorized_keys |
||
51 | </pre> |
||
52 | |||
53 | b) If you don't have file named *authorized_keys* rename id_rsa_titan.pub to *authorized_keys* and move it: |
||
54 | |||
55 | <pre> |
||
56 | mv ../id_rsa_titan.pub ./authorized_keys |
||
57 | </pre> |
||
58 | |||
59 | Logout from titan.utu.fi |
||
60 | |||
61 | Edit your local config file ... |
||
62 | |||
63 | <pre> |
||
64 | emacs config |
||
65 | </pre> |
||
66 | |||
67 | ... and add the following lines: |
||
68 | |||
69 | <pre> |
||
70 | Host titan |
||
71 | User YOUR_USERID |
||
72 | HostName titan.utu.fi |
||
73 | IdentityFile ~/.ssh/id_rsa_titan |
||
74 | </pre> |
||
75 | |||
76 | Replace YOUR_USERID with your user id in titan. |
||
77 | |||
78 | You setup is done now and you should be able to login: |
||
79 | |||
80 | <pre> |
||
81 | ssh titan |
||
82 | </pre> |