下载autossh。
然后是要设置利用密钥登陆。
最关键和另外最迷茫的一步是设置开机自启动。。因为是ubuntu 14。所以systemctl没法用。所以就制作成服务吧。。
vim /etc/init/autossh.conf
然后就可以利用service autossh start了
具体参考如下
description "autossh daemon for ssh tunnel"
start on net-device-up IFACE=eth0
stop on runlevel [01S6]
setuid usr_name
respawn
respawn limit 5 60
script
export AUTOSSH_FIRST_POLL=30
export AUTOSSH_GATETIME=0
export AUTOSSH_POLL=60
autossh -M 6777 -NR 2222:localhost:22 【远程ip】-i /home/usr_name/.ssh/id_rsa
end script
因为当初没有设置setuid。所以一直无法使用我本地的私钥。。。坑~~
本文介绍了在Ubuntu 14.04上安装和配置autossh进行反向代理的方法,包括使用密钥登录和设置开机启动。由于系统版本较旧,不能使用systemctl,因此通过创建init服务文件实现开机启动。详细步骤包括编写/etc/init/autossh.conf文件,设置相关环境变量,并确保使用正确的私钥。

593

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



