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