【发布时间】:2021-06-15 08:26:49
【问题描述】:
import paramiko
host = "172.21.14.48"
port = 22
username = "user"
password = "xxx*9841"
command = "ls"
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh.connect(host, port, username, password )
stdin, stdout, stderr = ssh.exec_command(command)
lines = stdout.readlines()
print(lines)
此代码工作 SSH 成功。但我需要使用相同的用户名和密码 ssh 到 cp@172.21.14.48。我尝试了下面的代码,但出现错误。
host = "cp@172.21.14.48"
错误信息为:ile "C:\Program Files\Python38\lib\socket.py", line 918,在getaddrinfo中 对于 _socket.getaddrinfo(host, port, family, type, proto, flags) 中的 res: socket.gaierror: [Errno 11003] getaddrinfo failed
有什么建议吗..?但是使用 putty 我可以 ssh 到 cp@172.21.14.48。
【问题讨论】:
-
Using username "cp". Keyboard-interactive authentication prompts from server: | Actual Username: | Actual Password: