SSHTunnelForwarder 和 dbeaver 中的 SSH 公钥身份验证失败

时间:2021-05-12 00:21:33

标签: python mysql ssh

我在 MacOS 上使用 ssh-keygen 命令生成了一个 SSH 密钥,标准问题。

我已经尝试获得在 Python 中使用 DBeaver 和使用 SSHTunnelForwarder 的密钥。两者都失败,并显示 Auth fail 的花园多样性消息。

我读到 here 我需要生成一个 PEM 密钥,现在我这样做了,我的密钥以

-----BEGIN RSA PRIVATE KEY-----

代替

-----BEGIN OPENSSH PRIVATE KEY-----

但这没有效果。奇怪的是,我可以使用两种密钥格式在终端上使用 key-auth 登录服务器。

当我使用 SSHTunnelForwarder 时:

# Have tried both OpenSSH and RSA (pem) formats
mypkey = paramiko.RSAKey.from_private_key_file('/Users/some_user/.ssh/id_rsa')

with SSHTunnelForwarder(
          ("host", 22),
          ssh_username="some_user",
          ssh_pkey=mypkey,
          remote_bind_address=("localhost", 3306)
     ) as server:
    with connect(
        host="127.0.0.1",
        user="some_user",
        password='some_password'
     ) as connection:
        print(connection)
[2021-05-11 15:43:55,476] {transport.py:1819} INFO - Connected (version 2.0, client OpenSSH_8.5)
[2021-05-11 15:43:55,801] {transport.py:1819} INFO - Authentication (publickey) failed.

如果我使用密码认证,我就没有问题。

0 个答案:

没有答案
相关问题