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

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

我正在尝试使用 Python 脚本连接 SFTP。由于 "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')

错误:

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

问题已解决。 找到 p 的值并将计算出的 p 包含在 dsa.py 文件中并保存。

如何计算P:

def _check_dsa_parameters(参数):

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

在此列表中包含 p:

(如果 parameters.p.bit_length() 不在 [1024, 2048, p-value] 中:)

修改后:

def _check_dsa_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整改效果很好。 谢谢