07-autossh部署手册¶
# 公网跳板机侧
yum -y install autossh sshpass
sed -i 's#GatewayPorts no#GatewayPorts yes#g' /etc/ssh/ssh_config
systemctl restart sshd
echo net.ipv4.ip_forward = 1 >>/etc/sysctl.conf;sysctl -p
iptables -t nat -I POSTROUTING -s 0.0.0.0/0 -j MASQUERADE
useradd autosshuser
echo 'VqaJqbfPzPmt' | passwd --stdin autosshuser
su - autosshuser
# 代理服务器侧
sshpass -p VqaJqbfPzPmt autossh -M 0 -CNR 40011:0.0.0.0:10000 autosshuser@39.97.102.162 -p33890 &
# 从公网跳板机侧登录连接代理服务器侧
ssh -p40011 test01@127.0.0.1
ssh -p40011 test01@39.97.102.162