使用端口转发和SSH跳板服务器来实现
-
阿里云服务器配置代理服务器
修改SSH配置文件(反隧道模式)
编辑/etc/ssh/sshd_config文件
vim /etc/ssh/sshd_config
在sshd_config中添加一条配置,打开转发功能,如下:
GatewayPorts yes
wq保存好以后,重启ssh
systemctl restart sshd
二、配置目标主机
执行如下的命令
内网
sudo ssh -T -f -N -g -R :51122:127.0.0.1:51122 root@xxx.xxx.xxx.xxx
阿里云服务器
ssh -p 51122 sq-machine-001@localhost
三、总是掉线请尝试如下解决办法
报错:client_loop: send disconnect: Broken pipe 配置/etc/ssh/ssh_config,添加如下内容
Host *
# 断开时重试连接的次数
ServerAliveCountMax 5
# 每隔5秒自动发送一个空的请求以保持连接
ServerAliveInterval 5
IPQoS=throughput
重启SSH
systemctl restart sshd