Paramiko: “not a valid RSA private key file”

前端 未结 3 1759
情歌与酒
情歌与酒 2020-12-16 18:43

I am trying connect to server using following spinet

ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())

ip = [\'x.x.x.x\']         


        
3条回答
  •  误落风尘
    2020-12-16 19:22

    The paramiko.RSAKey.from_private_key_file method requires the private key file to be in "PEM" format. Examine the file you're trying to read and see if it begins with a line that says:

    -----BEGIN RSA PRIVATE KEY-----
    

    If it doesn't have that line then it's not PEM.

    If it's not PEM then you'll have to find some way to create a PEM version of the private key. (EDIT: the original poster used PuTTY's puttygen utility to export the private key into a PEM-format file.)

    Make sure that the new file has the same ownership and limited access permissions that the original id_rsa file has, so that nobody can steal the key by reading the file. Then, obviously, modify your paramiko call to read the key from the new PEM-format file.

提交回复
热议问题