- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试访问隐藏在堡垒 EC2 实例后面的远程数据库 (AWS RDS) 之一。我可以通过我的 SQL 客户端轻松访问数据库,但无法通过我正在构建的 CLI 工具访问它(使用 Sequelize
和 tunnel-ssh
)。我在关注这个 GitHub Gist但它在任何地方都使用相同的值,不幸的是相当困惑。
我承认总体上对 SSH 隧道的理解很差,这在下面的示例中可能很明显。我的配置有问题吗?
数据库配置
Host: wdXXXXXXXXXXXX.XXXXXXXXX.XX-XXXXX-X.rds.amazonaws.com
Port: 5432
User: [DB_USER]
Password: [DB_PASSWORD]
Database: [DB_NAME]
堡垒配置
Server: 35.183.XX.XXX
Port: 22
Password:
SSH Key: ~/.ssh/id_rsa.aws
const config = {
// I don't need to specify any local values, do I?
// localHost: "127.0.0.1",
// localPort: 5432,
// This should be bastion config, correct?
username: "ec2-user",
host: 35.183.XX.XXX,
port: 22,
privateKey: require("fsf").readFileSync("/path/to/ssh/key"),
// This should be destination (database) config, correct?
dstHost: wdXXXXXXXXXXXX.XXXXXXXXX.XX-XXXXX-X.rds.amazonaws.com,
dstPort: 5432
};
// NOTE: If I don't have an "await" here, nothing seems to run inside the function itself (no consoles, etc)
const server = await tunnel(config, async (error, server) => {
if (error) return console.error(error);
const db = new Sequelize(DB_NAME, DB_USER, DB_PASSWORD, {
dialect: "postgres",
// NOTE: If this is already the destination in the SSH tunnel, should I use it again vs localhost?
host: "wdXXXXXXXXXXXX.XXXXXXXXX.XX-XXXXX-X.rds.amazonaws.com",
port: 5432
});
db.authenticate().then(async () => {
const orgs = await db.organization.findAll();
console.log("Successful query", orgs);
}).catch(err => {
console.error("DB auth error": err);
});
});
我上面的配置有问题吗?我在隧道配置中使用的值是否会影响我对隧道的理解?
另外,为什么似乎没有调用隧道回调 unless 我 await
函数(这似乎不是 Promise
)?
附:还有这个Sequelize GitHub提到通过 SSH 隧道与 Sequelize 连接的问题,但未提供示例。
最佳答案
我最终弄明白了这个问题并能够解决问题(在它开始后 12 小时)...数据库和堡垒配置在技术上是正确的,但我错误地传递了一些值(由于对 SSH 的理解有缺陷)隧道)。
数据库配置
Host: wdXXXXXXXXXXXX.XXXXXXXXX.XX-XXXXX-X.rds.amazonaws.com
Port: 5432
User: [DB_USER]
Password: [DB_PASSWORD]
Database: [DB_NAME]
堡垒配置
Server: 35.183.XX.XXX
Port: 22
Password:
SSH Key: ~/.ssh/id_rsa.aws
const config = {
// I have confirmed that the local values are unnecessary (defaults work)
// Configuration for SSH bastion
username: "ec2-user",
host: 35.183.XX.XXX,
port: 22,
privateKey: require("fs").readFileSync("/path/to/ssh/key"),
// Configuration for destination (database)
dstHost: wdXXXXXXXXXXXX.XXXXXXXXX.XX-XXXXX-X.rds.amazonaws.com,
dstPort: 5432
};
// NOTE: Moved to its own function, refactor likely fixed a few issues along the way
const getDB = () => new Promise((resolve, reject) => {
const tnl = await tunnel(config, async error => {
if (error) return reject(error);
const db = new Sequelize(DB_NAME, DB_USER, DB_PASSWORD, {
dialect: "postgres",
// NOTE: This is super important as the tunnel has essentially moved code execution to the database server already...
host: "localhost",
port: 5432
});
return resolve(db);
});
});
最后,主要更改是在 Sequelize 配置中使用 localhost
作为 SSH 隧道“出现”在数据库实例上,因此它应该引用自身。可能还有一些其他必要的调整(据我所知,我曾经尝试过),但最终我完好无损地出现了。
关于database - SSH 隧道到 Sequelize PostgreSQL 数据库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59272750/
是否有任何解决方案/补丁可以使 nginx 与上游的 socks 一起工作? 像这样: server { location / { proxy_pass socks5://ip:port
我的连接隧道有问题。因此,我正在使用两个安装了oracle xe(端口1521)的ubuntu服务器虚拟机,我们将它们称为uvm1和uvm2。我的目标是为两个服务器创建两个隧道,并将端口映射到主机,并
我正在使用 sshd 通过托管 Debian 的远程计算机隧道传输我所有的互联网流量。但是我的互联网连接变得很慢(大约 5 到 10 kbps!)。默认配置有什么问题会导致此问题吗? 提前致谢 最佳答
有没有办法在 OpenStreetMap 上显示所有隧道 + 道路?我正在为旅行制作自行车导航系统。在隧道中,我们丢失了 GPS 位置,因为隧道中没有 GPS 数据。我想知道我的位置进入隧道和离开隧道
我目前正在尝试在 Java 客户端(包括 Netty)和服务器之间实现一个 Http 隧道,所以我想知道是否有任何服务器也基于 Netty 来支持这个隧道,或者我应该构建服务器端我自己? 最佳答案 我
我希望从远程主机通过 SSH 建立一个端口。我希望将此实现为 oclif 插入;我希望用户体验如下所示: laptop$ give-jupyter http://localhost:4040/ lap
我正在寻找一种允许我使用 SSH 隧道连接到 R 中的 MySQL 服务器(而不是文件)的方法;我假设它需要 RCurl 和 RODBC 的组合,但我似乎无法让它正常工作。 我遇到了this post
基本上我想以编程方式通过代理服务器创建 SSL 隧道。我正在使用 openssl 创建 ssl 隧道,我可以创建它,但不确定如何通过代理服务器创建隧道。 最佳答案 快速谷歌搜索给我这个 pytunne
我想设置一个简单的 ssh 隧道,从本地机器到互联网上的机器。 我在用着 ssh -D 8080 -f -C -q -N -p 12122 @ 设置工作正常(我认为)导致 ssh 返回要求我提供的凭据
昨天,我接受了一家公司的 UI 开发面试。重点是面试官问了一个重要问题what is HTTP tunneling . 我从未遇到过有关 javascript、HTML 和 jquery 等 UI 内
对不起,长篇大论,我试图说得一清二楚。 * 一点背景 * 作为项目的一部分,我们需要能够使用远程桌面 (RDP) 从具有有效 IP 地址的服务器访问某些计算机(以下称为客户端)。这些客户端位于 NAT
我尝试了命令 killall ngrok,但我得到'killall' 未被识别为内部或外部命令、可操作程序或批处理文件。 killall 不应该和 ngrok 一起出现吗?我在互联网上找不到任何关于该
我需要连接到特定的 API,但该 API 只接受来 self 的配对服务器的请求。然后将这些信息包含在我们的网站中。 所以基本上我需要连接到服务器,使请求接收到答案并将其传输到我的主机,以便我可以使用
使用虚拟主机而不是部署的 Docker 容器,创建 ssh 隧道以便从我的本地机器访问分隔的机器对我来说是一个正常的工作过程。例如,将我的 psql 客户端连接到我只能从堡垒箱访问的 Postgres
我有一个从 Cloud Foundry 数据库转储数据的脚本,它的工作方式如下: cf ssh -L 33001:db.host:3306 --skip-remote-execution App &
我对以下系统架构有疑问: 假设我们有三台机器: SERVER A SERVER B EXTERNAL A SERVER A 正在提供一些流媒体服务,它在一个未知的网络后面,所以它在指定的端口上打开一个
我想从家庭计算机访问位于防火墙后面的工作计算机。 由于工作防火墙阻止意外的传入连接,我必须打开从工作计算机到家庭计算机的反向 SSH 隧道,如下所示: ssh -R 12345:localhost:2
已关闭。此问题不符合Stack Overflow guidelines 。目前不接受答案。 这个问题似乎不是关于 a specific programming problem, a software
我遇到了 SSH 隧道问题,我知道这可能是我的本地端口的权限问题,很可能是 127.0.0.1:3308。但是,我已经以管理员身份运行了我的程序(sudo python3 myprogram.py),
我使用此链接在 centos linux 中创建 ip 隧道 http://www.techonia.com/create-tunnel-interface-linux . 然后我想删除现有的隧道,我
我是一名优秀的程序员,十分优秀!