paramiko.ssh_exception.PasswordRequiredException: Private key file is encrypted

Viewed 5123

I'm trying to connect to server with paramiko but there's always some kind of problem with private key. id_dsa is an open ssh key, so I don't know what the problem can be.

Thanks in advance!

   import paramiko
   k = paramiko.RSAKey.from_private_key_file("C:/Users/bok/Desktop/id_dsa")

   c = paramiko.SSHClient()
   c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
   print ("connecting")
   c.connect( hostname = "3x.1x9.2x.2x", username = "taq4", password = "xxxxxx", pkey=k)
   print ("connected")
   commands = [ "ls", "pwd" ]
   for command in commands:
           print ("Executing {}").format( command )
           stdin , stdout, stderr = c.exec_command(command)
           print(stdout.read())
           print("Errors")
           print(stderr.read())
   c.close()

error:

paramiko.ssh_exception.PasswordRequiredException: Private key file is encrypted
1 Answers

It was your RSA key gen with password, just try it with your password private_key = paramiko.RSAKey.from_private_key_file(rsa_key, password)

Related