我有一台服务器,其中许多机器都被管理。我能够使用Paramiko在服务器上连接并运行命令,但是我无法登录该服务器上的计算机。脚本: -
#!/usr/bin/python
#to view time of EMS
import paramiko
ssh = paramiko.SSHClient()
enter code heressh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh.connect('x.x.x.x', username = 'AAA', password = 'BBB')
stdin, stdout, stderr = ssh.exec_command('date')
print(stdout.read())
client = paramiko.SSHClient()
ssh.connect('y.y.y.y', username= 'CCC', password='DDD')
socket.error: [Errno 10060] A connection attempt failed because the
connected party did not properly respond after a period of time, or
established connection failed because connected host has failed to
respond
socket.error: [Errno 10060]
基本上是一个连接的时机错误。
这可能是一些代理或网络问题。这是操作系统告诉您插座连接的时机,或者没有人在另一端听。Paramiko不是引起错误本身的原因。
我将确保通过OpenSSH客户端或NetCat nc -z <IP> 22
检查SSH服务是否在远程计算机中运行。服务ssh stastus。它应该显示活跃并运行。其他明智的运行命令下方。服务SSH开始。
正如Deepansh提到的那样,这也可能是代理错误。在这种情况下,需要将远程IP添加到no_proxy环境变量