Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/281.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python paramiko.ssh_exception.passwordrequiredeexception:私钥文件已加密_Python_Paramiko - Fatal编程技术网

Python paramiko.ssh_exception.passwordrequiredeexception:私钥文件已加密

Python paramiko.ssh_exception.passwordrequiredeexception:私钥文件已加密,python,paramiko,Python,Paramiko,我正试图用paramiko连接到服务器,但私钥总是有一些问题。id_dsa是一个开放的ssh密钥,所以我不知道会出现什么问题 提前谢谢 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())

我正试图用paramiko连接到服务器,但私钥总是有一些问题。id_dsa是一个开放的ssh密钥,所以我不知道会出现什么问题

提前谢谢

   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()
错误:

paramiko.ssh_exception.PasswordRequiredException: Private key file is encrypted

这是您的RSA密钥和密码,请使用您的密码进行尝试
private_key=paramiko.RSAKey。从_private_key_文件(rsa_key,密码)

提供有关您的用例的信息总是有帮助的,祝您好运!感谢更多的信息可以看到这个