Unknown exception: q must be exactly 160, 224, or 256 bits long
See original GitHub issueDue diligence #2140 appers to result in the same behavior
Describe the bug Attempting an SSH connection results in the following error: Unknown exception: q must be exactly 160, 224, or 256 bits long
To Reproduce Just run a pythonfile containing the code below. Right now, the private key is not encrypted and the config file in .ssh is empty.
Expected behaviour Successful SSH connection to the server
Environment
- What version of the Python interpreter are you using? 3.7.10
- What operating system are you using both client & server-side? Windows10 & Ubuntu
- Are you using OpenSSH server or something else? OpenSSH (Windows10 default)
- Which version or versions of the software are you using? fabric 2.6.0
- Have you, or can you, try some older releases to pin down where the bug appeared? Not tried yet
- How can the developers recreate the bug on their end? If possible, include a copy of your code, the command you used to invoke it, and the full output of your run (if applicable.)
from fabric import Connection
c = Connection(host='<IP>', user='<USER>', connect_kwargs={"key_filename": "C:\\Users\\<user>\\.ssh\\id_rsa"})
c.run('ls')
Output
Unknown exception: q must be exactly 160, 224, or 256 bits long
Traceback (most recent call last):
File "C:\Users\mle\AppData\Local\Continuum\anaconda3\envs\blackthorn\lib\site-packages\paramiko\transport.py", line 2109, in run
handler(self.auth_handler, m)
File "C:\Users\mle\AppData\Local\Continuum\anaconda3\envs\blackthorn\lib\site-packages\paramiko\auth_handler.py", line 298, in _parse_service_accept
sig = self.private_key.sign_ssh_data(blob)
File "C:\Users\mle\AppData\Local\Continuum\anaconda3\envs\blackthorn\lib\site-packages\paramiko\dsskey.py", line 116, in sign_ssh_data
).private_key(backend=default_backend())
File "C:\Users\mle\AppData\Local\Continuum\anaconda3\envs\blackthorn\lib\site-packages\cryptography\hazmat\primitives\asymmetric\dsa.py", line 243, in private_key
return backend.load_dsa_private_numbers(self)
File "C:\Users\mle\AppData\Local\Continuum\anaconda3\envs\blackthorn\lib\site-packages\cryptography\hazmat\backends\openssl\backend.py", line 657, in load_dsa_private_numbers
dsa._check_dsa_private_numbers(numbers)
File "C:\Users\mle\AppData\Local\Continuum\anaconda3\envs\blackthorn\lib\site-packages\cryptography\hazmat\primitives\asymmetric\dsa.py", line 142, in _check_dsa_private_numbers
_check_dsa_parameters(parameters)
File "C:\Users\mle\AppData\Local\Continuum\anaconda3\envs\blackthorn\lib\site-packages\cryptography\hazmat\primitives\asymmetric\dsa.py", line 134, in _check_dsa_parameters
raise ValueError("q must be exactly 160, 224, or 256 bits long")
ValueError: q must be exactly 160, 224, or 256 bits long
Traceback (most recent call last):
File ".\target_setup.py", line 4, in <module>
c.run('ls')
File "<decorator-gen-3>", line 2, in run
File "C:\Users\mle\AppData\Local\Continuum\anaconda3\envs\blackthorn\lib\site-packages\fabric\connection.py", line 29, in opens
self.open()
File "C:\Users\mle\AppData\Local\Continuum\anaconda3\envs\blackthorn\lib\site-packages\fabric\connection.py", line 636, in open
self.client.connect(**kwargs)
File "C:\Users\mle\AppData\Local\Continuum\anaconda3\envs\blackthorn\lib\site-packages\paramiko\client.py", line 446, in connect
passphrase,
File "C:\Users\mle\AppData\Local\Continuum\anaconda3\envs\blackthorn\lib\site-packages\paramiko\client.py", line 680, in _auth
self._transport.auth_publickey(username, key)
File "C:\Users\mle\AppData\Local\Continuum\anaconda3\envs\blackthorn\lib\site-packages\paramiko\transport.py", line 1580, in auth_publickey
return self.auth_handler.wait_for_response(my_event)
File "C:\Users\mle\AppData\Local\Continuum\anaconda3\envs\blackthorn\lib\site-packages\paramiko\auth_handler.py", line 236, in wait_for_response
raise e
File "C:\Users\mle\AppData\Local\Continuum\anaconda3\envs\blackthorn\lib\site-packages\paramiko\transport.py", line 2109, in run
handler(self.auth_handler, m)
File "C:\Users\mle\AppData\Local\Continuum\anaconda3\envs\blackthorn\lib\site-packages\paramiko\auth_handler.py", line 298, in _parse_service_accept
sig = self.private_key.sign_ssh_data(blob)
File "C:\Users\mle\AppData\Local\Continuum\anaconda3\envs\blackthorn\lib\site-packages\paramiko\dsskey.py", line 116, in sign_ssh_data
).private_key(backend=default_backend())
File "C:\Users\mle\AppData\Local\Continuum\anaconda3\envs\blackthorn\lib\site-packages\cryptography\hazmat\primitives\asymmetric\dsa.py", line 243, in private_key
return backend.load_dsa_private_numbers(self)
File "C:\Users\mle\AppData\Local\Continuum\anaconda3\envs\blackthorn\lib\site-packages\cryptography\hazmat\backends\openssl\backend.py", line 657, in load_dsa_private_numbers
dsa._check_dsa_private_numbers(numbers)
File "C:\Users\mle\AppData\Local\Continuum\anaconda3\envs\blackthorn\lib\site-packages\cryptography\hazmat\primitives\asymmetric\dsa.py", line 142, in _check_dsa_private_numbers
_check_dsa_parameters(parameters)
File "C:\Users\mle\AppData\Local\Continuum\anaconda3\envs\blackthorn\lib\site-packages\cryptography\hazmat\primitives\asymmetric\dsa.py", line 134, in _check_dsa_parameters
raise ValueError("q must be exactly 160, 224, or 256 bits long")
ValueError: q must be exactly 160, 224, or 256 bits long
Additional context Add any other context about the problem here.
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:9
Top Results From Across the Web
python3-paramiko: attempts to use RSA keys as DSA
Unknown exception : q must be exactly 160, 224, or 256 bits long. Traceback (most recent call last):
Read more >Unable to start migration in Plesk: q must be exactly 160, 224 ...
Failed to check SSH connection to the source server 'source' (203.0.113.2): q must be exactly 160, 224, or 256 bits long ...
Read more >ValueError: p must be exactly 1024, 2048, or 3072 bits long
I am trying to connect SFTP using Python script. I'm unable to connect due to "p error". import paramiko client = paramiko.SSHClient() client....
Read more >Can't connect to Jammy hosts (openssh >= 8.8p1-1)
Unknown exception : q must be exactly 160, 224, or 256 bits long [Full Traceback Below]. 4. Try with a newer paramiko:.
Read more >Ansible error - "msg": "q must be exactly 160, 224, or 256 bits ...
Hi I am trying to configure a VyOS VM deployed on ovirt. I am getting “msg”: “q must be exactly 160, 224, or...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I, too, encountered the exact same error. It turned out that I was supplying a username that did not exist on the target machine. The error went away after I corrected my mistake.
Fabric 1.10.2
Hi, I have the same issue when I use paramiko==2.11.0 or paramiko==2.10.1 and I don’t have the issue if I use paramiko=2.8.1 It seems that PR #1606 addressed this issue successfully : is there any reason for not fixing that in the recent releases of paramiko ?