Release1.0
step 01 ssh 连接公网服务器ip 47.95.233.183: 22 default port 22
username root
password *********
step 02 反向连接内网 ssh wvdon@localhost -p1234username :wvdon port 1234
Are you sure you want to continue connecting (yes/no)? yespassword
*******Release2.0
解决经常中断问题
Step 01 (同上) Step 02 ssh wvdon@localhost -p 22001password
******增加了监听端口,来达到连接稳定
方法内网 a
外网 b
a内网主机添加秘钥实现免登陆
ssh-keygen -t rsa -C "mail@wvdon.com"a添加到公网主机
ssh-copy-id b@111.123.123.123b公网主机添加监听
sudo vi /etc/ssh/sshd_configb添加
GatewayPorts yesb重启ssdh
sudo service sshd restarta安装autossh
sudo apt-get install autossha开启autossh
autossh -M 22002 -NfR 0.0.0.0:22001:localhost:22 root@47.95.233.183同时到阿里云服务器安全规则配置里面添加22001,22002端口
b连接 ssh wvdon@47.95.233.183 -p 22001a设置开机自启
sudo vi /etc/rc.locala添加代码
autossh -M 22002 -NfR 0.0.0.0:22001:localhost:22 root@47.95.233.183启sudo vi /etc/rc.local
a添加代码autossh -M 22002 -NfR 0.0.0.0:22001:localhost:22 root@47.95.233.183