我正在尝试设置 autossh 来运行通往我的 VPN 服务器的隧道。如果我使用
autossh -M 0 -o "ServerAliveInterval 30" -o "ServerAliveCountMax 3" -R 10000:localhost:22 console@<myvpnip>
Run Code Online (Sandbox Code Playgroud)
看起来效果很好,我可以使用隧道。
但是,如果我添加一个-f在后台运行的标志
autossh -f -M 0 -o "ServerAliveInterval 30" -o "ServerAliveCountMax 3" -R 10000:localhost:22 console@<myvpnip>
Run Code Online (Sandbox Code Playgroud)
当我尝试使用隧道时,我得到以下信息。
连接被拒绝
这里发生了什么?有没有办法在后台运行时记录任何错误?
小智 4
您使用flag的时候能输入密码吗-f?从 autossh 手册页:
请注意,带 autossh 的 -f 和带 ssh 的 -f 之间有一个关键区别:与 autossh 一起使用时,ssh 将无法询问密码或密码短语
您仍然可以使用该-f标志,但不能使用密码身份验证。而是使用VPN 服务器上的文件进行公钥身份验证。authorized_keys那么它应该与autossh -f -M 0 -N -o "ServerAliveInterval 30" -o "ServerAliveCountMax 3" -R 10000:localhost:22 console@<myvpnip>. 请注意 的额外-N选项ssh,仅适用于转发端口。
您应该能够使用tail -f /var/log/syslog或 来查看调试信息journalctl -f。