author | Oleksandr Gavenko <gavenkoa@gmail.com> |
Sun, 26 Sep 2010 16:52:43 +0300 | |
changeset 563 | 405f99f70163 |
parent 376 | 9d0020009266 |
child 867 | 0ad8febf7458 |
permissions | -rw-r--r-- |
371 | 1 |
-*- mode: outline; coding: utf-8 -*- |
2 |
||
3 |
* Maintaining key pair. |
|
4 |
||
5 |
$ ssh-keygen -t dsa # for DSA |
|
6 |
$ ssh-keygen -t rsa # for RSA |
|
7 |
$ ssh-keygen -t dsa -C comment # put own comment instead user@host |
|
8 |
$ ssh-keygen -t dsa -f my_dsa_key # store priv key under my_dsa_key |
|
9 |
# and pub key under my_dsa_key.pub |
|
10 |
||
11 |
$ ssh-keygen -y -f my_dsa_key # recover pub key from priv |
|
12 |
||
13 |
$ ssh-keygen -p -N "newphrase" -P "oldphrase" -f ~/.ssh/id_dsa |
|
14 |
# change passphrase of priv key |
|
15 |
||
374 | 16 |
$ ssh user@remote_host cat < $HOME/.ssh/id_rsa.pub cat ">>" .ssh/authorized_keys |
371 | 17 |
# public pub key on remote host |
18 |
||
19 |
* Using. |
|
20 |
||
21 |
** Shell login. |
|
22 |
||
23 |
$ ssh $user@$host |
|
24 |
$ ssh $user@$host:$port |
|
25 |
||
372
1a1b0f19eb51
Multiply private keys for ssh.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
371
diff
changeset
|
26 |
$ ssh -i ~/.ssh/my_dsa_key $user@$host |
1a1b0f19eb51
Multiply private keys for ssh.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
371
diff
changeset
|
27 |
|
371 | 28 |
or |
29 |
||
30 |
$ ssh -l $user $host |
|
31 |
$ ssh -l $user $host:$port |
|
32 |
||
33 |
** X session. |
|
34 |
||
35 |
$ ssh -X $user@$host |
|
36 |
||
372
1a1b0f19eb51
Multiply private keys for ssh.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
371
diff
changeset
|
37 |
** Multiply private keys. |
1a1b0f19eb51
Multiply private keys for ssh.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
371
diff
changeset
|
38 |
|
1a1b0f19eb51
Multiply private keys for ssh.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
371
diff
changeset
|
39 |
ssh try use all listen keys: |
1a1b0f19eb51
Multiply private keys for ssh.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
371
diff
changeset
|
40 |
|
1a1b0f19eb51
Multiply private keys for ssh.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
371
diff
changeset
|
41 |
$ ssh -i ./priv1 -i ./priv2 $user@$host |
1a1b0f19eb51
Multiply private keys for ssh.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
371
diff
changeset
|
42 |
|
1a1b0f19eb51
Multiply private keys for ssh.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
371
diff
changeset
|
43 |
or place in ~/.ssh/config: |
1a1b0f19eb51
Multiply private keys for ssh.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
371
diff
changeset
|
44 |
|
376
9d0020009266
Per host private key.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
375
diff
changeset
|
45 |
Host * |
372
1a1b0f19eb51
Multiply private keys for ssh.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
371
diff
changeset
|
46 |
IdentityFile ~/.ssh/identity # standard search path for protocol ver. 1 |
1a1b0f19eb51
Multiply private keys for ssh.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
371
diff
changeset
|
47 |
IdentityFile ~/.ssh/id_dsa # standard search path for RSA key protocol ver. 2 |
1a1b0f19eb51
Multiply private keys for ssh.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
371
diff
changeset
|
48 |
IdentityFile ~/.ssh/id_rsa # standard search path for DSA key protocol ver. 2 |
1a1b0f19eb51
Multiply private keys for ssh.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
371
diff
changeset
|
49 |
IdentityFile ~/.ssh/my_dsa |
1a1b0f19eb51
Multiply private keys for ssh.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
371
diff
changeset
|
50 |
IdentityFile ~/.ssh/another_dsa |
1a1b0f19eb51
Multiply private keys for ssh.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
371
diff
changeset
|
51 |
|
376
9d0020009266
Per host private key.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
375
diff
changeset
|
52 |
or per host private key: |
375
14c1b180f3f3
Per host ssh priv key.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
374
diff
changeset
|
53 |
|
14c1b180f3f3
Per host ssh priv key.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
374
diff
changeset
|
54 |
Host host1 # alias, that user provide at CLI |
14c1b180f3f3
Per host ssh priv key.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
374
diff
changeset
|
55 |
HostName host1.example.com # real host name to log into |
14c1b180f3f3
Per host ssh priv key.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
374
diff
changeset
|
56 |
User iam |
14c1b180f3f3
Per host ssh priv key.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
374
diff
changeset
|
57 |
IdentifyFile ~/.ssh/iam_priv_dsa |
14c1b180f3f3
Per host ssh priv key.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
374
diff
changeset
|
58 |
Host host2 # alias, that user provide at CLI |
14c1b180f3f3
Per host ssh priv key.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
374
diff
changeset
|
59 |
HostName 192.168.1.2 # real host IP to log into |
14c1b180f3f3
Per host ssh priv key.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
374
diff
changeset
|
60 |
User admin |
14c1b180f3f3
Per host ssh priv key.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
374
diff
changeset
|
61 |
IdentifyFile ~/.ssh/admin_priv_dsa |
14c1b180f3f3
Per host ssh priv key.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
374
diff
changeset
|
62 |
|
371 | 63 |
* Installing. |
64 |
||
65 |
** Windows. |
|
66 |
||
67 |
Use Cygwin OpenSSH. |
|
68 |
||
69 |
*** Installing sshd on Cygwin. |
|
70 |
||
71 |
* Install base packages and openssh. |
|
72 |
* Set CYGWIN env var to 'binmode tty ntsec'. |
|
73 |
* Create Windows user. |
|
74 |
* Recreate /etc/passwd: |
|
75 |
$ mkpasswd -l -u user >>/etc/passwd |
|
76 |
or |
|
77 |
$ mkpasswd -l >/etc/passwd |
|
78 |
* Register sshd: |
|
79 |
$ mkdir -p /home/user |
|
80 |
$ ssh-host-config -y |
|
81 |
* Start: |
|
82 |
$ net start sshd |
|
83 |
or |
|
84 |
$ cygrunsrv -S sshd |
|
85 |
* Check from remote host: |
|
86 |
$ ssh $gygwin_host -l user |
|
87 |
||
88 |
To stop service use |
|
89 |
||
90 |
$ net stop sshd |
|
91 |
or |
|
92 |
$ cygrunsrv -E sshd |
|
93 |
||
94 |
*** Запускаем SSH server на правах произвольного пользователя. |
|
95 |
||
96 |
* Создаем пользователя, например с именем user, задаем ему пароль, |
|
97 |
права (т.е. в какие группы будет входить) и т.д., пользователя не блокируем. |
|
98 |
* В консоле MMC добавляем оснастку "Параметры безопасности.". Модифицируем параметры: |
|
99 |
||
100 |
"Параметры безопасности."->"Локальные политики."->"Назначение прав пользователя." |
|
101 |
->"Вход в качестве службы."->добавить 'user'. |
|
102 |
||
103 |
"Параметры безопасности."->"Локальные политики."->"Назначение прав пользователя." |
|
104 |
->"Отклонить локальный вход."->удалить 'user' (если был установлен). |
|
105 |
||
106 |
XXX "Принудительное удаленнон завершение." |
|
107 |