在启动时尝试 ssh 隧道
Trying ssh tunel at startup
我需要我的服务器 (raspberry/raspbian) 在进程启动时(而不是在登录时)执行 shell 命令。
这是一个让我的服务器 "ssh tunel" 连接到数据库的命令:
ssh -fNg -L 3307:127.0.0.1:3306 <myuser>@<remoteIP> -p 22 -i <myprivatekey>
托管在我的服务器 (HTTP/apache2) 上的网站使用此隧道登录其数据库。
没有人登录到服务器,我看到 rc.local 是一种解决方案,但我认为它只有通过登录才有效?
尝试使用来自 here
的 crontab
解决方案
#crontab -e
@reboot /home/user/test.sh
请注意,如果无法从 non-super-user 设置中进行操作,请尝试使用 sudo:
sudo crontab -e
@reboot /home/user/test.sh
当然,在@reboot
之后放置正确的命令或脚本
我需要我的服务器 (raspberry/raspbian) 在进程启动时(而不是在登录时)执行 shell 命令。
这是一个让我的服务器 "ssh tunel" 连接到数据库的命令:
ssh -fNg -L 3307:127.0.0.1:3306 <myuser>@<remoteIP> -p 22 -i <myprivatekey>
托管在我的服务器 (HTTP/apache2) 上的网站使用此隧道登录其数据库。
没有人登录到服务器,我看到 rc.local 是一种解决方案,但我认为它只有通过登录才有效?
尝试使用来自 here
的crontab
解决方案
#crontab -e
@reboot /home/user/test.sh
请注意,如果无法从 non-super-user 设置中进行操作,请尝试使用 sudo:
sudo crontab -e
@reboot /home/user/test.sh
当然,在@reboot