【发布时间】:2021-08-17 05:07:06
【问题描述】:
我有一个像这样的 ssh 配置文件。 我有一个从 test2 到 host1 的代理跳转。
Host host1
Hostname xxxxxx.us-east-1.elb.amazonaws.com
Port 2222
User xxxx
IdentityFile ~/.ssh/cert
StrictHostKeyChecking no
UserKnownHostsFile /dev/null
KeepAlive yes
ServerAliveInterval 30
ServerAliveCountMax 30
Host test2
Hostname xx.xxx.xx.xxx
ProxyCommand ssh.exe host1 -q -W %h:%p host1
User ubuntu
IdentityFile ~/.ssh/cert
KeepAlive yes
StrictHostKeyChecking no
UserKnownHostsFile /dev/null
ServerAliveInterval 30
ServerAliveCountMax 30
我的 mongo 数据库主机:xxx-nonprod.cluster-xx.us-east-1.docdb.amazonaws.com
我必须使用主机 test2 使用 SSH 隧道到 Mongodb,但它使用 ProxyCommand
使用代理跳转我想通过 Mongo DB Compass 和 node js mongoose 使用 SSH 隧道连接到 mongodb。
如何使用 Mongo DB Compass 进行连接?
这里我没有输入ProxyCommand详细信息的选项。
如何使用 node js 进行连接?
我正在使用tunnel-ssh,我有一个参考代码,
var config = {
username:'ubuntu',
host:'xx.xxx.xx.xxx',
agent : process.env.SSH_AUTH_SOCK,
privateKey:require('fs').readFileSync('~/.ssh/cert'),
port:22,
dstPort:27017
};
var server = tunnel(config, function (error, server) {
});
我如何在此处输入 ProxyCommand 详细信息?或者请推荐任何可以解决这个问题的node js包。
【问题讨论】:
标签: mongodb mongoose ssh-tunnel mongodb-compass bastion-host