我的代码:
#!/usr/bin/env python3
from paramiko.client import SSHClient, WarningPolicy
HOST_NAME = "********"
USER_NAME = "********"
PASSWD = "********"
def ssh_setup():
client = SSHClient()
client.load_system_host_keys()
client.set_missing_host_key_policy(WarningPolicy)
client.connect(HOST_NAME, 22, USER_NAME, PASSWD)
return client
def main():
client = ssh_setup()
client.exec_command("DISPLAY=:0.0 notify-send \"Test\"")
client.close()
if __name__ == "__main__":
main()
运行时,我收到以下错误:
Traceback (most recent call last):
File "./test", line 30, in <module>
main()
File "./test", line 25, in main
client = ssh_setup()
File "./test", line 20, in ssh_setup
client.connect(HOST_NAME, 22, USER_NAME, PASSWD)
File "/usr/local/lib/python3.4/dist-packages/paramiko/client.py", line 348, in connect
server_key)
TypeError: missing_host_key() missing 1 required positional argument: 'key'
我可以直接进入有问题的机器(我的意思是,“我甚至不需要输入我的密码”很好)
答案 0 :(得分:5)
您需要将WarningPolicy对象传递给set_missing_host_key_policy
conda install my-package