一、登录过程
windows(Cygwin)---jumper跳板机-----> prod_server
配置Cygwin
使用 cygwin setup.exe 安装以下包
net
- nc
- openssh
editors
- vim
二、配置Windows客户端到jumper机ssh用户对等
$ scp root@jumper_IP:.ssh/authorized_keys ~/.ssh/
$ ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/home/Administrator/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/Administrator/.ssh/id_rsa.
Your public key has been saved in /home/Administrator/.ssh/id_rsa.pub.
The key fingerprint is:
37:c2:93:12:94:a6:73:6d:06:63:78:40:82:19:49:5d Administrator@XZ-20160330BIBA
The key's randomart image is:
+--[ RSA 2048]----+
|o*o.+E.. |
|+ o..B |
| =.+ |
| o .o+. |
| o.oS o |
| . + . |
| |
| |
| |
+-----------------+
$
$ cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
$ scp ~/.ssh/authorized_keys root@jumper_ip:.ssh/authorized_keys
$ ssh -l root jumper_ip -p 1234 date
Wed Jul 27 15:59:41 CST 2016
$
三、启动SSH守护进程
Administrator@XZ-20160330BIBA ~/.ssh
$ pwd
/home/Administrator/.ssh
Administrator@XZ-20160330BIBA ~/.ssh
$ more /home/Administrator/.ssh/config
## server 1 #####
Host 172.11.1.*
User root
ForwardAgent yes
ProxyCommand nc -x localhost:7070 %h %p 2
## server 2 #####
Host 192.168.1.*
User root
ForwardAgent yes
ProxyCommand nc -x localhost:7070 %h %p 2
/usr/bin目录新建ssh_deamon.sh并赋予执行权限
#!/usr/bin/sh
export PATH=/usr/bin;$PATH
ssh -ND localhost:7070 root@jumper_ip -p 1234
启动守护进程
$ /usr/bin/ssh_deamon.sh &
ssh登录目标主机
登录Cygwin客户端
ssh prod_server_ip
本文转自 pgmia 51CTO博客,原文链接:http://blog.51cto.com/heyiyi/1833970