我很想将 autossh 设置为在启动时运行,将它添加到/etc/rc.local.
此命令有效:
autossh -i /root/.ssh/id_rsa -R 2522:localhost:22 user@address
但是,如果我添加-f选项
autossh -f -i /root/.ssh/id_rsa -R 2522:localhost:22 user@address
ssh 会话未启动。
如您所见,我为我的身份文件使用了绝对路径,因此这似乎与此处所述的问题不同:后台的 autossh 不起作用
来自/var/log/syslog:
Oct 18 11:08:39 raspberrypi autossh[2417]: starting ssh (count 1)
Oct 18 11:08:39 raspberrypi autossh[2417]: ssh child pid is 2418
Oct 18 11:08:39 raspberrypi autossh[2417]: ssh exited with status 0; autossh exiting
Run Code Online (Sandbox Code Playgroud)
我在树莓派 autossh 版本 1.4c 上将它与 debian wheezy 一起使用。
可能是它正在将-f选项传递给 ssh 吗?
cro*_*nfy 15
当你在没有 的情况下启动 autossh 时-f,你会得到一个 shell。当 shell 工作时,你会得到端口转发。注销后,ssh 以退出代码 0 终止,并且 autossh 知道它不需要再次启动 ssh 会话。
当您使用 启动 autossh 时-f,它-f也会传递给 ssh。ssh 然后在后台运行并且不给你一个外壳。由于您没有指定任何其他标志或远程命令,ssh 会立即退出,状态为 0(无事可做),并且 autossh 不会重新启动它。
只需添加-N选项即可避免它:
-N Do not execute a remote command. This is useful for just forwarding
ports (protocol version 2 only)
Run Code Online (Sandbox Code Playgroud)
像这样:
autossh -f -N -i /root/.ssh/id_rsa -R 2522:localhost:22 user@address
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
6350 次 |
| 最近记录: |