Skip to content

[BUG] - Unable to use [email protected]  #2320

Open

Description

@sagraw2

Are you using paramiko as a client or server?

Client

What feature(s) aren't working right?

SSH, Keys/auth

What version(s) of paramiko are you using?

3.3.1

What version(s) of Python are you using?

3.8.10

What operating system and version are you using?

Ubuntu 20.04

If you're connecting as a client, which SSH server are you connecting to?

OpenSSH

If you're using paramiko as part of another tool, which tool/version?

No response

Expected/desired behavior

Trying to use a '[email protected]' loaded in ssh-agent to connect to a remote OpenSSH server.
This works fine with paramiko library version 3.1
This seems to be the offending commit :
0146cf7

Test Code:

ssh = SSHClient()
ssh.set_missing_host_key_policy(AutoAddPolicy())
try:
     ssh.connect(hostname=some_server, port=22, username=some_username)
     print("Connected successfully !!")
except Exception:
     print("Exception from ssh.connect !!")

Actual behavior

Fails with below error:

Traceback (most recent call last):
File "paramiko_test.py", line 154, in
sys.exit(main())
File "paramiko_test.py", line 62, in main
ssh.connect(hostname=some_server, port=22, username=some_username)
File "/home/someuser/.local/lib/python3.8/site-packages/paramiko/client.py", line 485, in connect
self._auth(
File "/home/someuser/.local/lib/python3.8/site-packages/paramiko/client.py", line 754, in _auth
self._transport.auth_publickey(username, key)
File "/home/someuser/.local/lib/python3.8/site-packages/paramiko/transport.py", line 1658, in auth_publickey
return self.auth_handler.wait_for_response(my_event)
File "/home/someuser/.local/lib/python3.8/site-packages/paramiko/auth_handler.py", line 248, in wait_for_response
raise e
File "/home/someuser/.local/lib/python3.8/site-packages/paramiko/transport.py", line 2185, in run
handler(m)
File "/home/someuser/.local/lib/python3.8/site-packages/paramiko/auth_handler.py", line 394, in _parse_service_accept
key_type, bits = self._get_key_type_and_bits(self.private_key)
File "/home/someuser/.local/lib/python3.8/site-packages/paramiko/auth_handler.py", line 218, in _get_key_type_and_bits
if key.public_blob:
File "/home/someuser/.local/lib/python3.8/site-packages/paramiko/agent.py", line 476, in getattr
raise AttributeError(name)
AttributeError: public_blob

How to reproduce

ssh = SSHClient()
ssh.set_missing_host_key_policy(AutoAddPolicy())
try:
     ssh.connect(hostname=some_server, port=22, username=some_username)
     print("Connected successfully !!")
except Exception:
     print("Exception from ssh.connect !!")

Anything else?

A temporary workaround (in paramiko\pkey.py Line 211) which works fine:

from paramiko import key_classes 
+++ if key_type.endswith("[email protected]"):
+++    key_type = 'ssh-ed25519'
for key_class in key_classes:

Note: Below is the output of this code snippet which prints the Pkey object retrieved from ssh-agent. Note the 'bits=0' for the first key which is a ed25519-cert. The second key is normal ED25519 key.

agent = Agent()
agent_keys = agent.get_keys()
for key in agent_keys:
   print(key)

PKey(alg=ED25519-CERT, bits=0, fp=SHA256:data retracted, comment='data retracted')
PKey(alg=ED25519, bits=256, fp=SHA256:data retracted, comment='data retracted')

Activity

  1. airtower-luna commented on May 28, 2024

    @airtower-luna

    I'm seeing what appears to be the same error if there's an id_ed25519_sk key loaded into the SSH agent, regardless of whether that's actually the key that needs to be used for the connection.

  2. oriordan commented on Aug 12, 2024

    @oriordan

    +1 would it be possible to merge the above PR to fix this?

  3. boehmc-sw commented on Aug 30, 2024

    @boehmc-sw

    I am running into the same issue. Thanks for the PR! Would be great getting this in.

  4. tmancill commented on Aug 31, 2024

    @tmancill

    +1 for considering the patch in the PR. The issue has been affecting Duplicity in Debian since the introduction of 3.4.0 (see Debian bug 1071675).

    I have tested with the patch applied to 3.4.1 and verified that it addresses the problem with ed25519 keys.

  5. pikeas commented on Sep 19, 2024

    @pikeas

    Just bit by this as well while using pyinfra (downstream client with a paramiko dependency) - took some time to track this back to Paramiko.

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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions