1 |
$Id$ |
$Id$ |
2 |
|
|
3 |
$Log$ |
$Log$ |
4 |
Revision 1.1 2002/02/11 01:22:17 cvsjoko |
Revision 1.3 2003/04/04 21:04:01 joko |
5 |
Initial revision |
a safer way to do this.... |
6 |
|
|
7 |
|
Revision 1.2 2003/03/20 05:57:31 joko |
8 |
|
updated |
9 |
|
|
10 |
|
Revision 1.1.1.1 2002/02/11 01:22:17 cvsjoko |
11 |
|
first checkin' |
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
------------------------------------------------------------------------------ |
16 |
|
1. local machine (e.g.: your laptop) (want to login to remote one) |
17 |
|
|
18 |
|
THIS METHOD IS a) CLUMSY AND b) DANGEROUS!!! |
19 |
|
PLEASE USE METHOD 2. TO DO THIS! |
20 |
|
|
21 |
|
- check if you can login to the remote machine |
22 |
|
via "normal" password authentication: |
23 |
|
- ssh <username>@<remote_machine> |
24 |
|
|
25 |
|
- create keys: |
26 |
|
- rsa-keys: ssh-keygen |
27 |
|
- dsa-keys: ssh-keygen -d |
28 |
|
|
29 |
|
- create authorized_keys: |
30 |
|
- cd ~/.ssh/ |
31 |
|
- rsa-keys: cat identity.pub >> authorized_keys |
32 |
|
- dsa-keys: cat id_dsa.pub >> authorized_keys |
33 |
|
|
34 |
|
- take care of proper file-permissions |
35 |
|
- chmod -R og-rwx ~/.ssh |
36 |
|
|
|
------------------------------------------ |
|
|
- local machine: |
|
|
- check if you can login to the remote machine via "normal" password authentication |
|
|
- create rsa-keys with "ssh-keygen" |
|
|
- authorize yourself |
|
|
- cd ~/.ssh/ |
|
|
- cat identity.pub >> authorized_keys |
|
|
- take care of proper file-permissions |
|
|
- chmod -R og-rwx ~/.ssh |
|
37 |
- authorize remote machines / distribute "authorized_keys" |
- authorize remote machines / distribute "authorized_keys" |
38 |
- scp authorized_keys <username>@<remote_machine>:~/.ssh/ |
- scp authorized_keys <username>@<remote_machine>:~/.ssh/ |
39 |
|
this is dangerous!!! it will overwrite the "authorized_keys" file completely |
40 |
|
|
41 |
- test login to remote machine |
- test login to remote machine |
42 |
- ssh <remote_machine> |
- ssh <remote_machine> |
43 |
------------------------------------------ |
|
44 |
|
2. remote machine (e.g.: a backup server) (want to login to this one) |
45 |
|
|
46 |
|
which is machine is what? |
47 |
|
<worker> the machine you are working on |
48 |
|
<remote> the machine you want to log in |
49 |
|
|
50 |
|
which account is what? |
51 |
|
<service> is the account on <worker> (this one might execute some cronjobs) |
52 |
|
<joko_backup> is the account on <remote> |
53 |
|
|
54 |
|
[key generation] one-time preparations needed for <worker>: |
55 |
|
x useradd service |
56 |
|
x su service |
57 |
|
x ssh-keygen -d |
58 |
|
|
59 |
|
[key distribution] to be executed on <remote>: |
60 |
|
x useradd joko_backup |
61 |
|
x su joko_backup |
62 |
|
x ssh service@<worker> "cat ~/.ssh/id_dsa.pub" >> ~/.ssh/authorized_keys |
63 |
|
the (") with the first (remote) command are important! |
64 |
|
otherwise your *local* shell would expand the tilde (~) |
65 |
|
|
66 |
|
[key distribution] to be executed on <worker>: |
67 |
|
This is an alternative to above if the account on <remote> already exists, |
68 |
|
and it is somehow required not to execute commands |
69 |
|
actively/manually at the <remote> side. Picture this: "the worker works". |
70 |
|
#> cat ~/.ssh/id_dsa.pub | ssh joko@netfrag.org "cat - >> ~/.ssh/authorized_keys" |
71 |
|
#> cat ~/.ssh/id_dsa.pub | ssh joko@gharb.tune.sytes.net "cat - >> ~/.ssh/authorized_keys" |
72 |
|
|
73 |
|
If the account at remote side doesn't exists, |
74 |
|
this shortcut might create it from the <worker> side as well: |
75 |
|
x ssh root@<remote> "useradd joko_backup" |
76 |
|
|
77 |
|
[login] test it on <worker>: |
78 |
|
x su service |
79 |
|
x ssh joko_backup@<remote-machine> |
80 |
|
|
81 |
|
------------------------------------------------------------------------------ |
82 |
|
|
83 |
|
|
84 |
------------------------------------------ |
------------------------------------------ |