远程主机上
/etc/ssh/sshd_config中,开启
GatewayPorts yes
systemctl reload sshd
本地:
ssh -CqTnN -R 0.0.0.0:9000:localhost:7070 root@109.105.4.65
109.105.4.65 9000端口的流量会发送到 localhost的7070端口
SecureSRT设置: 选项->会话选项->远程/x11
ssh -CqTnN -R 0.0.0.0:9999:54.209.106.26:22 root@109.105.4.65
将109.105.4.65的9999端口流量发送到54.209.106.26的22端口
所以ssh 109.105.4.65 -p9999,可以连接54.209.106.26
ssh -CqTnN -R 0.0.0.0:9999:54.209.106.26:22 localhost
========================================================
安装nc
yum install nmap-ncat.x86_64
# cat config
StrictHostKeyChecking no
UserKnownHostsFile /dev/null
host gitlab.gcloud.srcb.com
hostname gitlab.gcloud.srcb.com
port 29675
host aws
hostname 54.209.106.26
port 22
IdentityFile /root/.ssh/FARM-1634-5b25a9a4.us-east-1-1.pem
user root
============
# vi config
Host aws
HostName 54.209.106.26
ProxyCommand /bin/nc --proxy 109.105.4.65:7070 %h %p
User root
IdentityFile /root/.ssh/FARM-1634-5b25a9a4.us-east-1-1.pem
=================
Host 54.211.46.*
HostName %h
ProxyCommand /bin/nc --proxy 109.105.4.17:7081 %h %p
User ubuntu
IdentityFile /root/.ssh/FARM-1634-5b25a9a4.us-east-1-1.pem
================
ssh -oProxyCommand="nc --proxy 109.105.4.65:7070 %h %p" -i .ssh/FARM-1634-5b25a9a4.us-east-1.pem root@54.209.106.26