Paramiko ValueError "p must be exactly 1024, 2048, or 3072 bits long"

Question:

I am trying to connect SFTP using Python script. I’m unable to connect due to “p error”.

import paramiko
client = paramiko.SSHClient()
client.load_system_host_keys()
client.connect('####.com', username='####', password='###')
stdin, stdout, stderr = client.exec_command('ls -l')

Error:

ValueError: p must be exactly 1024, 2048, or 3072 bits long

Asked By: manuzz

||

Answers:

Find the value of p and include calculated p in dsa.py file and save it.

how to calculate P:

def _check_dsa_parameters(parameters):

    print(parameters.p.bit_length(),"value of p")
    if parameters.p.bit_length() not in [1024, 2048, 3024]:

include p in this list:

(if parameters.p.bit_length() not in [1024, 2048, p-value]:)

After modification:

def _check_dsa_parameters(parameters):

    if parameters.p.bit_length() not in [1024, 2048, p-value]:
        raise ValueError("p must be exactly 1024, 2048, or 3072 bits long")

Post to rectification it worked Fine.
Thanks

Answered By: manuzz
Categories: questions Tags: , , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.