pahaz / sshtunnel

SSH tunnels to remote server.
MIT License
1.23k stars 184 forks source link

How can I pass an argument (disabled_algorithms) to the connection function of an instance of SSHClient in paramiko? #258

Open murata100 opened 2 years ago

murata100 commented 2 years ago

The following code worked fine. (If disabled_algorithms is not specified, AuthenticationException: Authentication failed.)

import paramiko
with paramiko.SSHClient() as ssh:
    ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
    with open(PATH_OF_PKEY) as f:
        pk = paramiko.RSAKey.from_private_key(f)
        ssh.connect(
            HOST, PORT, SSHUSER, pkey=pk,
            disabled_algorithms=dict(pubkeys=['rsa-sha2-256', 'rsa-sha2-512']))

But the code below didn't work.

import sshtunnel
with sshtunnel.SSHTunnelForwarder(
        (HOST, PORT),
        ssh_username=SSHUSER,
        ssh_pkey=PATH_OF_PKEY,
        remote_bind_address=(MySQLHOST, MySQLPORT),
        disabled_algorithms=dict(pubkeys=['rsa-sha2-256', 'rsa-sha2-512'])
    ) as server:
    server.start()

I got ValueError

ValueError: Unknown arguments: {'disabled_algorithms': {'pubkeys': ['rsa-sha2-256', 'rsa-sha2-512']}}

How can I pass an argument (disabled_algorithms) to the connection function of an instance of SSHClient in paramiko?

murata100 commented 2 years ago

Here's why I need disabled_algorithms: RSA key auth failing from paramiko 2.9.x client to dropbear server