我尝试使用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
答案 0 :(得分:0)
这是您的带密码的RSA密钥生成器,只需尝试使用您的密码 private_key = paramiko.RSAKey.from_private_key_file(rsa_key,密码)