试图将Python与SSH隧道连接起来

发布于 2025-02-11 21:34:51 字数 889 浏览 0 评论 0原文

我正在尝试通过SSHTUNNEL和PSYCOPG2将脚本连接到PostgreSQL数据库。我可以通过DBEAVER访问我的凭据。因此,基本上我有一个:

ssh配置

ssh paramateres与以下相似的地方

: IP:'SomeProxy.something.io'
用户名:'user1'
私钥:ID_RSA文件的路径
密码:'password1'

这是我的代码:

try:

    print('Connecting to the postgre database...')

   

    with SSHTunnelForwarder(

            "someproxy.something.io",

            ssh_username = "User1",

            ssh_private_key = "C:/~ /.ssh/User1_id_rsa",

            ssh_private_key_password = "Password1",

            remote_bind_adress = ("mydatabase-postgres.something.io", 5432)

    ) as server:

        server.start()

我遇到了此错误:

ValueError: Unknown arguments: {'remote_bind_adress': ('mydatabase-postgres.something.io', 5432)}

I'm trying to connect my script to a PostgreSQL database via sshtunnel and psycopg2. I can access the DB with my credentials through DBeaver. So, basically I have this:

SSH Configuration

Where the SSH paramateres are similar to this:

Host/IP: 'someproxy.something.io'
User Name: 'User1'
Private key: Path to an id_rsa file
Passphrase: 'Password1'

This is my code:

try:

    print('Connecting to the postgre database...')

   

    with SSHTunnelForwarder(

            "someproxy.something.io",

            ssh_username = "User1",

            ssh_private_key = "C:/~ /.ssh/User1_id_rsa",

            ssh_private_key_password = "Password1",

            remote_bind_adress = ("mydatabase-postgres.something.io", 5432)

    ) as server:

        server.start()

And I'm getting this error:

ValueError: Unknown arguments: {'remote_bind_adress': ('mydatabase-postgres.something.io', 5432)}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

留蓝 2025-02-18 21:34:51

您在参数名称中有一个错别字:remote_bind_adress->远程_BIND_ADDRESS

You have a typo in the parameter name: remote_bind_adress -> remote_bind_address.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文