Repository navigation
Closed
Description
Nearly same issue as this previous one: #1135.
Paramiko version 2.7.2
Python version 3.7.3
Environment Raspberry Pi (Raspbian Buster)
ssh keys were generated in PEM format: ssh-keygen -t rsa -m PEM. Confirmed that I can ssh from the RPi to the target host with the private key from the command line.
>>> client = paramiko.SSHClient()
>>> pk = paramiko.RSAKey.from_private_key_file('/home/pi/.ssh/id_rsa')
>>> paramiko.util.log_to_file('/home/pi/ssh_log.log')
>>> ip_address='192.168.1.114'
>>> port=22
>>> user='markd'
>>> client.connect(ip_address, username=user, port=port, pkey=pk, look_for_keys=False)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/pi/mycroft-core/.venv/lib/python3.7/site-packages/paramiko/client.py", line 446, in connect
passphrase,
File "/home/pi/mycroft-core/.venv/lib/python3.7/site-packages/paramiko/client.py", line 764, in _auth
raise saved_exception
File "/home/pi/mycroft-core/.venv/lib/python3.7/site-packages/paramiko/client.py", line 664, in _auth
self._transport.auth_publickey(username, pkey)
File "/home/pi/mycroft-core/.venv/lib/python3.7/site-packages/paramiko/transport.py", line 1580, in auth_publickey
return self.auth_handler.wait_for_response(my_event)
File "/home/pi/mycroft-core/.venv/lib/python3.7/site-packages/paramiko/auth_handler.py", line 250, in wait_for_response
raise e
paramiko.ssh_exception.AuthenticationException: Authentication failed.
Contents of /home/pi/ssh_log.log:
DEB [20201224-03:09:52.656] thr=1 paramiko.transport: Local version/idstring: SSH-2.0-paramiko_2.7.2
DEB [20201224-03:09:52.670] thr=1 paramiko.transport: Remote version/idstring: SSH-2.0-OpenSSH_8.4
INF [20201224-03:09:52.671] thr=1 paramiko.transport: Connected (version 2.0, client OpenSSH_8.4)
DEB [20201224-03:09:52.691] thr=1 paramiko.transport: kex algos:['curve25519-sha256', '[email protected]', 'ecdh-sha2-nistp256', 'ecdh-sha2-nistp384', 'ecdh-sha2-nistp521', 'diffie-hellman-group-exchange-sha256', 'diffie-hellman-group14-sha256', 'diffie-hellman-group16-sha512', 'diffie-hellman-group18-sha512'] server key:['rsa-sha2-512', 'rsa-sha2-256', 'ecdsa-sha2-nistp256', 'ssh-ed25519'] client encrypt:['[email protected]', '[email protected]', 'aes256-ctr', '[email protected]', 'aes128-ctr'] server encrypt:['[email protected]', '[email protected]', 'aes256-ctr', '[email protected]', 'aes128-ctr'] client mac:['[email protected]', '[email protected]', '[email protected]', '[email protected]', 'hmac-sha2-256', 'hmac-sha1', '[email protected]', 'hmac-sha2-512'] server mac:['[email protected]', '[email protected]', '[email protected]', '[email protected]', 'hmac-sha2-256', 'hmac-sha1', '[email protected]', 'hmac-sha2-512'] client compress:['none', '[email protected]'] server compress:['none', '[email protected]'] client lang:[''] server lang:[''] kex follows?False
DEB [20201224-03:09:52.691] thr=1 paramiko.transport: Kex agreed: curve25519-sha256@libssh.org
DEB [20201224-03:09:52.692] thr=1 paramiko.transport: HostKey agreed: ssh-ed25519
DEB [20201224-03:09:52.692] thr=1 paramiko.transport: Cipher agreed: aes128-ctr
DEB [20201224-03:09:52.693] thr=1 paramiko.transport: MAC agreed: hmac-sha2-256
DEB [20201224-03:09:52.693] thr=1 paramiko.transport: Compression agreed: none
DEB [20201224-03:09:53.018] thr=1 paramiko.transport: kex engine KexCurve25519 specified hash_algo <built-in function openssl_sha256>
DEB [20201224-03:09:53.020] thr=1 paramiko.transport: Switch to new keys ...
DEB [20201224-03:09:53.021] thr=2 paramiko.transport: Adding ssh-ed25519 host key for 192.168.1.114: b'e8da00c074f40ae87587b4cb2c1f2d3a'
DEB [20201224-03:09:53.022] thr=2 paramiko.transport: Trying SSH key b'e98158f6b3a46c0474fac8ce9e018874'
DEB [20201224-03:09:53.058] thr=1 paramiko.transport: userauth is OK
INF [20201224-03:09:56.527] thr=1 paramiko.transport: Authentication (publickey) failed.Reacted by Nati Tessema and leezj-cbm
Metadata
Metadata
Assignees
Labels
No labels
Activity
sagarkhushalani commentedon Feb 25, 2021
Same issue; I can log in from command line, with the same key to the same host, but paramiko always gets an
authentication failed.Some things to note:
Log for v2.0.0 is below
rowanz commentedon Aug 11, 2021
I think I have the same issue when connecting to a new host -- Paramiko fails on 2.7.2 with something like
interestingly though, if I ssh to it first via the command line, and then try Paramiko, everything works! so not quite sure what the problem is...
Trophime commentedon Mar 12, 2022
I'm facing a similar issue on debian/Testing (bookworm)
When using paramiko from Ubuntu/20.04 LTS to connect to debian/Testing (openssh 8.8p1) it fails
But it works when on connecting to a debian/Stable (openssh 8.4p1)
Hope it helps to find what is the problem...
Trophime commentedon Mar 12, 2022
I observe this behavior for 2.8.1 and 2.6.0
Trophime commentedon Mar 12, 2022
see: #1915