开始之前:两台linux(centos,ubuntu都一样)master,node,要做的是将node的22端口映射到master的1234端口上,这里只是示例,其他端口的映射也一样。
在node上安装autossh:
yum install autossh #centos
apt-get install autossh #ubuntu使用ssh建立tunnel,在node上执行:
ssh -NfR 1234:localhost:22 master隧道开启:将node的22端口映射到master的1234端口
此时在master上ssh localhost -p 1234就能连接到node
既然ssh就能开启隧道,那我们还要用autossh干吗呢?答案很简单,因为autossh有个auto啊,ssh建立的隧道在ssh连接超时后会自动断开,使用autossh可以可以在断开后自动恢复连接。
使用autossh建立tunnel
autossh -M 5678 -NfR 1234:localhost:22 master
本文介绍如何使用SSH建立端口转发隧道,并通过Autossh实现隧道的自动恢复功能,确保远程连接稳定可靠。
969

被折叠的 条评论
为什么被折叠?



