自动反向SSH隧道

时间:2015-11-02 16:40:53

标签: linux ssh startup rc

我需要通过ssh连接到我的办公室计算机,但所有端口都被阻止,没有任何关系。我想连接反向SSH隧道。为此,我想使用它一直打开的外部服务器,我想设置我的办公室计算机,以便在启动时(登录前)运行ssh命令。

我尝试修改/etc/rc.local。这些是权限:

-rwxr-xr-x 1 root root 385 nov  2 17:27 /etc/rc.local

文件:

#!/bin/sh -e
#
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.
sleep 1
sshpass -p 'pass' ssh -N -R 9091:localhost:22 user@server &
exit 0

运行/etc/rc.local允许我从家用计算机连接到我的办公室计算机,因此代码执行了它应该做的事情,但它在启动时似乎没有做任何事情。

如何在启动过程中运行脚本?

感谢。

0 个答案:

没有答案