windows上的端口8083
 ubuntu上的端口9781
 666.com是ubuntu服务器地址
1、ubuntu服务器
创建秘钥
 ssh-keygen
进入秘钥目录
 cd /root/.ssh/
下载私钥
 sz id_rsa
复制到windows的c:\users\dyf\.ssh目录下
vim /etc/ssh/sshd_config
将#gatewayports no
 改为
 gatewayports yes
重启服务
 systemctl restart sshd.service 
 2、windows本地主机
创建秘钥
 ssh-keygen -t rsa -b 4096
复制公钥
 c:\users\dyf\.ssh目录下id_rsa.pub里的值复制到ubuntu服务器的/root/.ssh/authorized_keys文件里
 3、ubuntu服务器
增加防火墙
 sudo iptables -a input -p tcp --dport 9781 -j accept
 4、windows本地主机
创建隧道
 在c:\users\dyf\.ssh目录下执行cmd命令
ssh -i .\id_rsa -fcnr 9781:127.0.0.1:8083 -o serveraliveinterval=60 -o serveralivecountmax=120 -p 22 ubuntu@666.com
输入ubuntu服务器密码
5、ubuntu服务器
查看端口
 netstat -antup | grep 9781
发送消息
 echo '666' | nc 666.com 9781
接收消息
 windows上的127.0.0.1:8083可以接收到666
 
             我要评论
我要评论 
                                             
                                             
                                            
发表评论