author | Oleksandr Gavenko <gavenkoa@gmail.com> |
Sun, 29 Mar 2009 17:59:05 +0300 | |
changeset 62 | 4cda4557f554 |
parent 4 | c676a664a5ef |
permissions | -rw-r--r-- |
1
743f7a15697a
Move admin doc from utils proj.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
1 |
-*- mode: outline; coding: windows-1251 -*- |
743f7a15697a
Move admin doc from utils proj.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
2 |
|
743f7a15697a
Move admin doc from utils proj.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
3 |
* SSH server on cygwin. |
743f7a15697a
Move admin doc from utils proj.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
4 |
|
743f7a15697a
Move admin doc from utils proj.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
5 |
* Инсталлируем стандартный набор утилит Cygwin + пакет openssh. |
743f7a15697a
Move admin doc from utils proj.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
6 |
* Устанавливаем переменную окружения CYGWIN=binmode tty ntsec. |
743f7a15697a
Move admin doc from utils proj.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
7 |
Это можно сделать глобально или через cygwin.bat (только для клиента). |
743f7a15697a
Move admin doc from utils proj.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
8 |
set CYGWIN=binmode tty ntsec |
743f7a15697a
Move admin doc from utils proj.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
9 |
* Создать пользователя (XXX как сделать чтобы этот пользователь не мог логиниться?), |
743f7a15697a
Move admin doc from utils proj.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
10 |
например с именем user. |
743f7a15697a
Move admin doc from utils proj.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
11 |
* Обновить /etc/passwd |
743f7a15697a
Move admin doc from utils proj.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
12 |
$ mkpasswd -l -u user >>/etc/passwd |
743f7a15697a
Move admin doc from utils proj.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
13 |
или |
743f7a15697a
Move admin doc from utils proj.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
14 |
$ mkpasswd -l >/etc/passwd |
743f7a15697a
Move admin doc from utils proj.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
15 |
для обносления всех записей. |
743f7a15697a
Move admin doc from utils proj.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
16 |
* В приглашении bash: |
743f7a15697a
Move admin doc from utils proj.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
17 |
$ mkdir -p /home/user |
743f7a15697a
Move admin doc from utils proj.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
18 |
$ ssh-host-config -y |
743f7a15697a
Move admin doc from utils proj.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
19 |
Стартуем сервер: |
743f7a15697a
Move admin doc from utils proj.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
20 |
$ net start sshd |
743f7a15697a
Move admin doc from utils proj.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
21 |
или |
743f7a15697a
Move admin doc from utils proj.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
22 |
$ cygrunsrv -S sshd |
743f7a15697a
Move admin doc from utils proj.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
23 |
* На удаленной машине логинимся: |
743f7a15697a
Move admin doc from utils proj.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
24 |
$ ssh 192.168.1.26 -l user |
743f7a15697a
Move admin doc from utils proj.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
25 |
* Остановить сервер |
743f7a15697a
Move admin doc from utils proj.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
26 |
$ cygrunsrv -E sshd |
743f7a15697a
Move admin doc from utils proj.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
27 |
|
743f7a15697a
Move admin doc from utils proj.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
28 |
** Запускаем SSH server на правах произвольного пользователя. |
743f7a15697a
Move admin doc from utils proj.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
29 |
|
743f7a15697a
Move admin doc from utils proj.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
30 |
* Создаем пользователя, например с именем user, задаем ему пароль, |
743f7a15697a
Move admin doc from utils proj.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
31 |
права (т.е. в какие группы будет входить) и т.д., пользователя не блокируем. |
743f7a15697a
Move admin doc from utils proj.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
32 |
* В консоле MMC добавляем оснастку "Параметры безопасности.". Модифицируем параметры: |
743f7a15697a
Move admin doc from utils proj.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
33 |
|
743f7a15697a
Move admin doc from utils proj.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
34 |
"Параметры безопасности."->"Локальные политики."->"Назначение прав пользователя." |
743f7a15697a
Move admin doc from utils proj.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
35 |
->"Вход в качестве службы."->добавить 'user'. |
743f7a15697a
Move admin doc from utils proj.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
36 |
|
743f7a15697a
Move admin doc from utils proj.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
37 |
"Параметры безопасности."->"Локальные политики."->"Назначение прав пользователя." |
743f7a15697a
Move admin doc from utils proj.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
38 |
->"Отклонить локальный вход."->удалить 'user' (если был установлен). |
743f7a15697a
Move admin doc from utils proj.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
39 |
|
743f7a15697a
Move admin doc from utils proj.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
40 |
XXX "Принудительное удаленнон завершение." |
743f7a15697a
Move admin doc from utils proj.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
41 |
|
743f7a15697a
Move admin doc from utils proj.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
42 |
* SSH client. |
743f7a15697a
Move admin doc from utils proj.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
43 |
|
743f7a15697a
Move admin doc from utils proj.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
44 |
** SSH client on Windows. |
743f7a15697a
Move admin doc from utils proj.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
45 |
|
743f7a15697a
Move admin doc from utils proj.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
46 |
*** ssh from Cygwin. |
743f7a15697a
Move admin doc from utils proj.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
47 |
|
743f7a15697a
Move admin doc from utils proj.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
48 |
* Инсталируем openssh из Cygwin. |
743f7a15697a
Move admin doc from utils proj.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
49 |
* В приглашении bash набираем |
743f7a15697a
Move admin doc from utils proj.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
50 |
$ ssh user@192.168.1.38 |
743f7a15697a
Move admin doc from utils proj.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
51 |
или |
743f7a15697a
Move admin doc from utils proj.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
52 |
$ ssh -l user 192.168.1.38 |
4
c676a664a5ef
Reverse SSH Tunneling.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1
diff
changeset
|
53 |
|
c676a664a5ef
Reverse SSH Tunneling.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1
diff
changeset
|
54 |
* Reverse SSH Tunneling |
c676a664a5ef
Reverse SSH Tunneling.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1
diff
changeset
|
55 |
|
c676a664a5ef
Reverse SSH Tunneling.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1
diff
changeset
|
56 |
Have you ever wanted to ssh to your Linux box that sits behind NAT? Now you can with |
c676a664a5ef
Reverse SSH Tunneling.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1
diff
changeset
|
57 |
reverse SSH tunneling. This document will show you step by step how to set up reverse SSH |
c676a664a5ef
Reverse SSH Tunneling.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1
diff
changeset
|
58 |
tunneling. The reverse SSH tunneling should work fine with Unix like systems. |
c676a664a5ef
Reverse SSH Tunneling.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1
diff
changeset
|
59 |
|
c676a664a5ef
Reverse SSH Tunneling.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1
diff
changeset
|
60 |
Let's assume that Destination's IP is 192.168.20.55 (Linux box that you want to access). |
c676a664a5ef
Reverse SSH Tunneling.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1
diff
changeset
|
61 |
|
c676a664a5ef
Reverse SSH Tunneling.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1
diff
changeset
|
62 |
You want to access from Linux client with IP 138.47.99.99. |
c676a664a5ef
Reverse SSH Tunneling.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1
diff
changeset
|
63 |
Destination (192.168.20.55) <- |NAT| <- Source (138.47.99.99) |
c676a664a5ef
Reverse SSH Tunneling.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1
diff
changeset
|
64 |
|
c676a664a5ef
Reverse SSH Tunneling.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1
diff
changeset
|
65 |
SH from the destination to the source (with public ip) using command below: |
c676a664a5ef
Reverse SSH Tunneling.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1
diff
changeset
|
66 |
|
c676a664a5ef
Reverse SSH Tunneling.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1
diff
changeset
|
67 |
$ ssh -R 19999:localhost:22 sourceuser@138.47.99.99 |
c676a664a5ef
Reverse SSH Tunneling.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1
diff
changeset
|
68 |
|
c676a664a5ef
Reverse SSH Tunneling.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1
diff
changeset
|
69 |
port 19999 can be any unused port. |
c676a664a5ef
Reverse SSH Tunneling.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1
diff
changeset
|
70 |
Now you can SSH from source to destination through SSH tuneling: |
c676a664a5ef
Reverse SSH Tunneling.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1
diff
changeset
|
71 |
|
c676a664a5ef
Reverse SSH Tunneling.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1
diff
changeset
|
72 |
$ ssh localhost -p 19999 |
c676a664a5ef
Reverse SSH Tunneling.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1
diff
changeset
|
73 |
|
c676a664a5ef
Reverse SSH Tunneling.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1
diff
changeset
|
74 |
3rd party servers can also access 192.168.20.55 through Destination (138.47.99.99). |
c676a664a5ef
Reverse SSH Tunneling.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1
diff
changeset
|
75 |
Destination (192.168.20.55) <- |NAT| <- Source (138.47.99.99) <- Bob's server |
c676a664a5ef
Reverse SSH Tunneling.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1
diff
changeset
|
76 |
|
c676a664a5ef
Reverse SSH Tunneling.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1
diff
changeset
|
77 |
From Bob's server: |
c676a664a5ef
Reverse SSH Tunneling.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1
diff
changeset
|
78 |
|
c676a664a5ef
Reverse SSH Tunneling.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1
diff
changeset
|
79 |
$ ssh sourceuser@138.47.99.99 |
c676a664a5ef
Reverse SSH Tunneling.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1
diff
changeset
|
80 |
|
c676a664a5ef
Reverse SSH Tunneling.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1
diff
changeset
|
81 |
After the sucessful login to Source: |
c676a664a5ef
Reverse SSH Tunneling.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1
diff
changeset
|
82 |
|
c676a664a5ef
Reverse SSH Tunneling.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1
diff
changeset
|
83 |
$ ssh localhost -p 19999 |
c676a664a5ef
Reverse SSH Tunneling.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1
diff
changeset
|
84 |
|
c676a664a5ef
Reverse SSH Tunneling.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1
diff
changeset
|
85 |
The connection between destination and source must be alive at all time. Tip: you may run |
c676a664a5ef
Reverse SSH Tunneling.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1
diff
changeset
|
86 |
a command (e.g. watch, top) on Destination to keep the connection active. |