author | Oleksandr Gavenko <gavenkoa@gmail.com> |
Tue, 28 Jan 2014 17:14:35 +0200 | |
changeset 1554 | 7eadf0928d57 |
parent 1386 | 864237ce5f1b |
child 1595 | 7f512266d262 |
permissions | -rw-r--r-- |
1334
9bf0d5a1f0cf
Include common header with quick links.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1032
diff
changeset
|
1 |
.. -*- coding: utf-8; -*- |
9bf0d5a1f0cf
Include common header with quick links.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1032
diff
changeset
|
2 |
.. include:: HEADER.rst |
1002 | 3 |
|
4 |
=========== |
|
5 |
SSH/sshd. |
|
6 |
=========== |
|
1032
4decc3e00bb6
Fix coding and contents.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1002
diff
changeset
|
7 |
.. contents:: |
1002 | 8 |
|
1385
acb36dfe5d09
Debugging ssh client.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1384
diff
changeset
|
9 |
Debugging ssh client. |
acb36dfe5d09
Debugging ssh client.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1384
diff
changeset
|
10 |
===================== |
acb36dfe5d09
Debugging ssh client.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1384
diff
changeset
|
11 |
:: |
acb36dfe5d09
Debugging ssh client.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1384
diff
changeset
|
12 |
|
acb36dfe5d09
Debugging ssh client.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1384
diff
changeset
|
13 |
$ ssh -vvv ... |
acb36dfe5d09
Debugging ssh client.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1384
diff
changeset
|
14 |
|
1002 | 15 |
Maintaining key pair. |
16 |
===================== |
|
17 |
:: |
|
18 |
||
19 |
$ ssh-keygen -t dsa # for DSA |
|
20 |
$ ssh-keygen -t rsa # for RSA |
|
21 |
$ ssh-keygen -t dsa -C comment # put own comment instead user@host |
|
22 |
$ ssh-keygen -t dsa -f my_dsa_key # store priv key under my_dsa_key |
|
23 |
# and pub key under my_dsa_key.pub |
|
24 |
||
25 |
$ ssh-keygen -y -f my_dsa_key # recover pub key from priv |
|
26 |
||
27 |
$ ssh-keygen -p -N "newphrase" -P "oldphrase" -f ~/.ssh/id_dsa |
|
28 |
# change passphrase of priv key |
|
29 |
||
30 |
$ ssh $user@$host cat ">>" "~/.ssh/authorized_keys" <~/.ssh/id_rsa.pub |
|
31 |
# public pub key on remote host |
|
32 |
||
33 |
Shell login. |
|
34 |
============ |
|
35 |
:: |
|
36 |
||
37 |
$ ssh $user@$host |
|
38 |
$ ssh $user@$host:$port |
|
39 |
||
40 |
$ ssh -i ~/.ssh/my_dsa_key $user@$host |
|
41 |
||
42 |
or:: |
|
43 |
||
44 |
$ ssh -l $user $host |
|
45 |
$ ssh -l $user $host:$port |
|
46 |
||
1384 | 47 |
X11 forwarding. |
48 |
=============== |
|
49 |
||
50 |
Enable X11 forwarding on remote host in ``~/.ssh/config`` or ``/etc/ssh_config``:: |
|
51 |
||
52 |
X11Forwarding yes |
|
53 |
||
54 |
then login to this host by:: |
|
1002 | 55 |
|
56 |
$ ssh -X $user@$host |
|
57 |
||
1384 | 58 |
or by using trusted X11 forwarding:: |
59 |
||
60 |
$ ssh -Y $user@$host |
|
61 |
||
1386
864237ce5f1b
X11Forwarding does not work with OpenSSH under Cygwin
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1385
diff
changeset
|
62 |
See: |
864237ce5f1b
X11Forwarding does not work with OpenSSH under Cygwin
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1385
diff
changeset
|
63 |
|
864237ce5f1b
X11Forwarding does not work with OpenSSH under Cygwin
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1385
diff
changeset
|
64 |
http://x.cygwin.com/docs/faq/cygwin-x-faq.html#q-ssh-no-x11forwarding |
864237ce5f1b
X11Forwarding does not work with OpenSSH under Cygwin
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1385
diff
changeset
|
65 |
X11Forwarding does not work with OpenSSH under Cygwin |
1384 | 66 |
|
1002 | 67 |
Multiply private keys. |
68 |
====================== |
|
69 |
||
70 |
ssh try use all listen keys:: |
|
71 |
||
72 |
$ ssh -i ./priv1 -i ./priv2 $user@$host |
|
73 |
||
74 |
or place in ~/.ssh/config:: |
|
75 |
||
76 |
Host * |
|
77 |
IdentityFile ~/.ssh/identity # standard search path for protocol ver. 1 |
|
78 |
IdentityFile ~/.ssh/id_dsa # standard search path for RSA key protocol ver. 2 |
|
79 |
IdentityFile ~/.ssh/id_rsa # standard search path for DSA key protocol ver. 2 |
|
80 |
IdentityFile ~/.ssh/my_dsa |
|
81 |
IdentityFile ~/.ssh/another_dsa |
|
82 |
||
83 |
or per host private key:: |
|
84 |
||
85 |
Host host1 # alias, that user provide at CLI |
|
86 |
HostName host1.example.com # real host name to log into |
|
87 |
User iam |
|
88 |
IdentifyFile ~/.ssh/iam_priv_dsa |
|
89 |
Host host2 # alias, that user provide at CLI |
|
90 |
HostName 192.168.1.2 # real host IP to log into |
|
91 |
User admin |
|
92 |
IdentifyFile ~/.ssh/admin_priv_dsa |
|
93 |
||
94 |
Installing sshd on Cygwin. |
|
95 |
========================== |
|
96 |
||
97 |
* Install base packages and openssh. |
|
1382
9297a8f7e3f3
Fix: CYGWIN=tty is no longer supported.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1334
diff
changeset
|
98 |
* Set CYGWIN env var to 'binmode ntsec'. |
1002 | 99 |
* Create Windows user. |
100 |
* Recreate /etc/passwd:: |
|
101 |
$ mkpasswd -l -u user >>/etc/passwd |
|
102 |
or:: |
|
103 |
$ mkpasswd -l >/etc/passwd |
|
104 |
||
105 |
* Register sshd:: |
|
106 |
$ mkdir -p /home/user |
|
107 |
$ ssh-host-config -y |
|
108 |
* Start:: |
|
109 |
$ net start sshd |
|
110 |
or:: |
|
111 |
$ cygrunsrv -S sshd |
|
112 |
||
113 |
* Check from remote host:: |
|
114 |
$ ssh $gygwin_host -l user |
|
115 |
||
116 |
To stop service use:: |
|
117 |
||
118 |
$ net stop sshd |
|
119 |
||
120 |
or:: |
|
121 |
||
122 |
$ cygrunsrv -E sshd |
|
123 |
||
124 |
Запускаем SSH server на правах произвольного пользователя. |
|
125 |
---------------------------------------------------------- |
|
126 |
||
1383 | 127 |
* Создаем пользователя, например с именем user, задаем ему пароль, права (т.е. |
128 |
в какие группы будет входить) и т.д., пользователя не блокируем. |
|
129 |
* В консоле MMC добавляем оснастку "Параметры безопасности". Модифицируем |
|
130 |
параметры: |
|
1002 | 131 |
|
1383 | 132 |
"Параметры безопасности" --> "Локальные политики" --> "Назначение прав |
133 |
пользователя." --> "Вход в качестве службы" --> добавить 'user'. |
|
1002 | 134 |
|
1383 | 135 |
"Параметры безопасности" --> "Локальные политики" --> "Назначение прав |
136 |
пользователя" --> "Отклонить локальный вход" --> удалить 'user' (если был |
|
137 |
установлен). |
|
1002 | 138 |
|
1383 | 139 |
XXX "Принудительное удаленное завершение." |
1002 | 140 |