格式

ssh -L <local port>:<remote host>:<remote port> <SSH servername>

示例

# ssh -L 3307:$server2:3306 user@$server1

实现的效果是使用user登录$server1之后建立本地3307端口到远程$server2:3306端口的隧道,通过访问本地3307端口访问远程$server2:3306端口,前提是$server1可以访问$server2:3306端口;

 

windows xshell这样配置

【原创】Linux基础之SSH隧道/端口转发

 

【原创】Linux基础之SSH隧道/端口转发

 

putty设置

【原创】Linux基础之SSH隧道/端口转发

 

如果需要自动重连,使用autossh

# yum install autossh

# autossh -M 0 -L 0.0.0.0:$local_port:127.0.0.1:$report_port $remote_user@$remote_ip -o "ServerAliveInterval 60" -o "ServerAliveCountMax 3"

 

相关文章:

  • 2022-01-27
  • 2021-12-04
  • 2021-05-19
  • 2022-12-23
猜你喜欢
  • 2022-01-19
  • 2021-10-26
  • 2021-12-04
  • 2021-11-09
  • 2021-09-10
  • 2022-12-23
  • 2021-11-15
相关资源
相似解决方案