我设法创建了Raspberry Pi 2和我的服务器(具有静态IP的服务器)之间的反向SSH隧道,并且工作正常。我在服务器上使用的用户帐户被称为“ksproxy”(它不是真正的“代理”,但无论如何)。如何使用autossh获得持久的反向SSH隧道?
现在我试图让autossh
(来自Debian/Raspbian包autossh
)也能工作,但我没有成功。我可能会接近。
(我已经改变了这里的真实IP在这个问题37.xxx.yyy.zzz
不发布服务器的实际IP)
这里是工作的罚款:(无autossh)
在此RPI:
[email protected]:~ $ ssh -N -R 20000:localhost:22 [email protected]
在服务器(具有静态IP):
[email protected]:~$ ssh [email protected] -t -p 20000
[email protected]'s password:
[email protected]:~ $
所以一切工作正常:我输入密码,我得到一个终端/提示。
我甚至可以从我的桌面访问树莓派(通过服务器首先进入),这样做的:
ssh -t [email protected] "ssh [email protected] -p 20000"
[email protected] password:
[email protected]'s password:
...
[email protected]:~
它首先要求服务器的密码,然后为皮的密码,一切都很好。
到目前为止这么好。
现在,我尝试相同的,但这次autossh:
[email protected]:~ $ autossh -M 20000 -N -i /home/rspi/.ssh/id_rsa [email protected]
[email protected]:~$ ssh [email protected] -p 20000
这个“作品”,但它只是卡在那里,什么都不做。
我试图“-vvv”输出的ssh命令,但它只是表明没有任何事情正在进行。
如果我尝试另一个端口,它失败:
[email protected]:~$ ssh [email protected] -p 1234
ssh: connect to host localhost port 1234: Connection refused
如果我尝试正确的端口(20000),但这次与-t
PARAM,同样的事情:它“作品”,但我不明白没有终端/提示。
这里的一个的输出-vvv
[email protected]:~$ ssh -vvv [email protected] -t -p 20000
OpenSSH_6.7p1 Debian-5+deb8u1, OpenSSL 1.0.1k 8 Jan 2015
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug2: ssh_connect: needpriv 0
debug1: Connecting to localhost [127.0.0.1] port 20000.
debug1: Connection established.
debug1: key_load_public: No such file or directory
debug1: identity file /home/ksproxy/.ssh/id_rsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/ksproxy/.ssh/id_rsa-cert type -1
debug1: key_load_public: No such file or directory
...
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_6.7p1 Debian-5+deb8u1
它不要求口令,它不表示任何终端/提示。
我在这里不理解或做错了什么?
请注意,我不认为这是一个防火墙的问题,因为“非autossh”方法工作正常(但我没有得到自动的“总是”/重新连接功能)。我真的想让autossh工作(我知道我可以找到一个解决方法,就像一些crontab自动重新启动我的手动SSH隧道,但这可能比autossh工作更脆弱)。
btw通过谷歌搜索类似的问题,我最终在这里:也许这不是最合适的SE网站这样的问题?如果不是,我应该问这个问题? (它不是特定于Raspberry,它不是真的用于ServerFault - 或者是它,...) –
SuperUser是这个地方。 – Jakuje
@Jajuke:好的,非常感谢,完成了! –