我通过机器A(本地的,在几个路由器后面)B(中间商)和C(远程的,我试图从A访问的机器)配置了反向ssh隧道。
把所有相关的钥匙放在所有机器上,如果我这样做的话
autossh -M 10984 -o "PubkeyAuthentication=yes" -o "PasswordAuthentication=no -i /home/user/.ssh/id_rsa.pub 9999:localhost:22 user@machine-B在机器A上,我可以从机器C连接到机器B(中间人),通过端口9999连接到A。
现在,我补充说
autossh -M 10984 -N -f -o "PubkeyAuthentication=yes" -o "PasswordAuthentication=no -i /home/user/.ssh/id_rsa.pub 9999:localhost:22 user@machine-B &到我的/etc/rc.local文件中,这样命令就会在引导、重新启动时执行,现在隧道就不能工作了。我犯了个错误
autossh[1966]: starting ssh (count 14)
autossh[1966]: ssh child pid is 4916
autossh[1966]: ssh exited with error status 255; restarting ssh 在赛斯日志上。
我的/etc/rc.local有:
autossh -M 10984 -N -f -o "PubkeyAuthentication=yes" -o "PasswordAuthentication=no" -i /home/user/.ssh/id_rsa.pub -R 9999:localhost:22 user@machine-B &
ethtool -s eth0 autoneg on
exit 0知道我做错了什么吗?
更新:我注意到了
autossh -M 10984 -N -f -o "PubkeyAuthentication=yes" -o "PasswordAuthentication=no" -i /home/user/.ssh/id_rsa.pub -R 9999:localhost:22 user@machine-B在命令行上工作,因此:
sudo autossh -M 10984 -N -f -o "PubkeyAuthentication=yes" -o "PasswordAuthentication=no" -i /home/user/.ssh/id_rsa.pub -R 9999:localhost:22 user@machine-B使命令行提示我输入公钥密码,即使它没有附加密码。我在另一个堆栈问题(我找不到)上看到,-f标志阻止ssh请求进一步的输入。由于rc.local上的thigs作为根运行(据我所知),我认为这就是为什么autossh一直创建退出失败的ssh进程的原因。事实上,删除-f标志使ubuntu不断创建窗口,提示我输入密码。创建密钥时,我没有输入任何密码。
发布于 2018-01-09 09:56:48
我想你是在遵循这个网站的指示:https://raymii.org/s/tutorials/Autossh_持久的_tunnels.html
正如您正确地观察到的,尝试执行
sudo autossh -M 10984 -N -f -o "PubkeyAuthentication=yes" -o "PasswordAuthentication=no" -i /home/user/.ssh/id_rsa.pub -R 9999:localhost:22 user@machine-B导致在启动时自动失败的附加提示。
一个简单的解决方案是将SSH密钥从“user”复制到root。
cp /home/user/.ssh/id_rsa.pub /root/.ssh/id_rsa.pub
cp /home/user/.ssh/id_rsa /root/.ssh/id_rsa -R这对我来说没问题。复制是从“root”帐户执行的,因此所有权自动设置为“root”。然后从终端(而不是引导)运行autossh命令,这样主机就知道了。修改引导命令,将键的新路径包含在根文件夹中,您就设置好了。
https://unix.stackexchange.com/questions/411731
复制相似问题