【发布时间】:2017-08-08 08:54:45
【问题描述】:
我正在尝试使用 GUI 和命令行连接到远程 MongoDB 服务器,但我认为我的 SSH 部分有问题。
我相信远程服务器上配置了不允许 SSH 隧道的配置,我不确定从哪里开始查找,请记住我还没有 sudo 访问权限。
我可以使用独立的 SSH 工具(putty、ssh via command line、winscp)连接到远程服务器,但尝试连接到 MongoDB 失败
我尝试在我的机器和远程机器之间创建一个隧道
ssh -i ~/.ssh/private-key -N -L27018:localhost:27017 user@site.com -vvv
然后在我的机器上运行以下命令
$ mongo --port 27018
MongoDB shell version: 2.6.10
connecting to: 127.0.0.1:27018/test
2017-08-08T08:28:36.152+0000 DBClientCursor::init call() failed
2017-08-08T08:28:36.153+0000 Error: DBClientBase::findN: transport error: 127.0.0.1:27018 ns: admin.$cmd query: { whatsmyuri: 1 } at src/mongo/shell/mongo.js:148
exception: connect failed
隧道日志显示了这一点
debug1: Connection to port 27018 forwarding to localhost port 27017 requested.
debug2: fd 6 setting TCP_NODELAY
debug2: fd 6 setting O_NONBLOCK
debug3: fd 6 is O_NONBLOCK
debug1: channel 2: new [direct-tcpip]
debug3: send packet: type 90
debug3: receive packet: type 92
channel 2: open failed: administratively prohibited: open failed
debug2: channel 2: zombie
debug2: channel 2: garbage collecting
debug1: channel 2: free: direct-tcpip: listening port 27018 for localhost port 27017, connect from 127.0.0.1 port 41672 to 127.0.0.1 port 27018, nchannels 3
debug3: channel 2: status: The following connections are open:
作为测试,我设置了一台带有 mongodb 的 vagrant 机器,并且能够通过命令行和 GUI 从我的主机连接。
是否有任何特定的配置变量可能会阻止我通过 SSH 连接?
远程服务器有这些设置,但在 vagrant 机器上切换它们并没有什么不同,我仍然能够连接
#bind_ip = 127.0.0.1
【问题讨论】:
-
关于设置 SSH 隧道的问题最好在serverfault.com 或superuser.com 上询问。不,MongoDB 本身并没有阻止使用 SSH 隧道,问题完全与您的配置有关,这不是编程问题。