Skip to content

Paramiko not working with Openssh 8.8p1 #1915

Closed

Description

@flavius

After an upgrade of openssh from 8.7p1 to 8.8p1, paramiko does not work any more.

Sample script:

  def native_ssh_command(self, host, username, cmds, debug=True):
    results = []

    client = paramiko.SSHClient()
    client.set_missing_host_key_policy(paramiko.WarningPolicy())
    client.connect(host, 22, username)
    session = client.get_transport().open_session()
    paramiko.agent.AgentRequestHandler(session)
    for cmd in cmds:
        if debug:
            print(cmd)
        (stdin, stdout, stderr) = client.exec_command(cmd)
        cmd_result = {"cmd": cmd, "stdout": stdout.read(), "stderr": stderr.read(), "exit_code": stdout.channel.recv_exit_status()}
        results.append(cmd_result)
        if stdout.channel.recv_exit_status() != 0:
            if debug:
                print(f"Command '{cmd=}' failed on host '{host=}'!")
                print(cmd_result)
            break;
    client.close()
    return results

Activity

  1. ploxiln commented on Oct 24, 2021

    @ploxiln
    Contributor

    This is probably because you are using an RSA key to authenticate. OpenSSH-8.8 disables support for RSA keys/signatures using SHA-1 hash by default. Paramiko does not yet support RSA keys/signatures using SHA-2 hashes. You'll need something like #1643 and probably some additional tweaks. Or, use an ECDSA or ED25519 key instead.

  2. austinbutler commented on Nov 9, 2021

    @austinbutler

    As stated using an ED25519 key works. I was able to get an RSA key working by combining #1643 and #1606 in a branch off paramiko 2.8.0.

  3. manfred-kaiser commented on Nov 27, 2021

    @manfred-kaiser

    The problem is, that "ssh-rsa" has multiple meanings. One problem with paramiko is, that it reads the key-type from a publickey file and the key-type is used as hash type during the authentication. This only works for sha1 hashes, because they are also defined as "ssh-rsa".

    According to RFC-4252, publickey authentication is split in 2 steps. The first (optional) step is to ask the server, if a publickey is known. In the second step a signature is sent to the server, which is the real authentication step.
    If the first step fails, because SHA1 hashes are not supported, the whole authentication fails.

    Paramiko has implemented the publickey authentication with both steps and fails on the first step, which is the publickey lookup.

    When speaking of hash types SSH defines ssh-rsa as SHA1 hash. For SHA512 hashes the hash type is rsa-sha2-512.

    I have implemented a test application, which is able to lookup, if a publickey is known by the server. This application only implements the first step of the publickey authentication process. When using the current implementation of paramiko, the key lookup fails for OpenSSH 8.8.

    m.add_string(self.private_key.public_blob.key_type)

    If the key is a "ssh-rsa" key type, my application forces a "rsa-sha2-512" hash, and the key loopup is possible:

    https://github.com/ssh-mitm/ssh-mitm/blob/dbc920d9a93304b24a5b71d766c6210c531eb9b8/ssh_proxy_server/authentication.py#L52:L55

    @bitprophet We will try to fix this issue in the next weeks. Is there a deadline for the fix?

  4. bitprophet commented on Dec 23, 2021

    @bitprophet
    Member

    Paramiko 2.9 will be out today and fixes this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions