繁体   English   中英

无法从Windows使用Paramiko登录Linux服务器

[英]Not able to log into Linux server using Paramiko from Windows

嗨,我正在通过远程桌面使用Windows Server 2008 R2。

我的要求是登录Linux计算机并将程序包复制到Windows Server 2008计算机。

但是仅在第一阶段,我就陷入了困境,无法登录Linux服务器。 我在远程桌面上编写了以下代码。

def Package_Copying(self,timeout=60):

    ssh=paramiko.SSHClient()

    ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())

    ssh.connect("10.82.110.9",timeout=70,username='XXXX',password='XXXXX',look_for_keys=False)



    ssh_stdin, ssh_stdout, ssh_stderr = ssh.exec_command('ls -ltr')

    print "output",  ssh_stdout.read() 

    self.close()

当我执行相同的操作时,出现以下错误。

"error: (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')"

当我用腻子做同样的事情时,我可以登录。但是登录需要3到4秒钟。

以下是同一服务器的Ping跟踪

C:\Users\Administrator>ping 10.82.110.9

Pinging 10.82.110.9 with 32 bytes of data:

Reply from 10.82.110.9: bytes=32 time=229ms TTL=234

Reply from 10.82.110.9: bytes=32 time=229ms TTL=234

Reply from 10.82.110.9: bytes=32 time=230ms TTL=234

Reply from 10.82.110.9: bytes=32 time=229ms TTL=234


Ping statistics for 10.82.110.9:

    Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),

Approximate round trip times in milli-seconds:

    Minimum = 229ms, Maximum = 230ms, Average = 229ms


C:\Users\Administrator>

当我在paramiko中设置了不正确的端口时,遇到了类似的错误,请尝试添加端口标志:

 ssh.connect("10.82.110.9",port=22,timeout=70,username='XXXX',password='XXXXX',look_for_keys=False)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM