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