0

This is an example which works fine on friend's computer:

import paramiko

host = "157.178.35.134"
port = 222
username = "stackoverflow"
password = "e2fghK3"

transport = paramiko.Transport((host, port))

transport.connect(username = username, password = password)

sftp = paramiko.SFTPClient.from_transport(transport)

import sys
path = './file.testy'    #server
localpath = '/home/iwtu/test' 
sftp.put(localpath, path)

sftp.close()
transport.close()
print 'Upload done.' 

However I have the following problem.

>>> import paramiko

Warning (from warnings module):
  File "C:\DevelopingTools\Python\lib\site-packages\Crypto\Util\randpool.py", line 40
    RandomPool_DeprecationWarning)
RandomPool_DeprecationWarning: This application uses RandomPool, which is BROKEN in older releases.  See http://www.pycrypto.org/randpool-broken
>>> host = '157.178.35.134'
>>> port = 222
>>> username = 'stackoverflow'
>>> password = 'e2fghK3'
>>> t = paramiko.Transport((host,port))
>>> t.connect(username = username, password = password)

    Traceback (most recent call last):
      File "<pyshell#6>", line 1, in <module>
        t.connect(username = username, password = password)
      File "C:\DevelopingTools\Python\lib\site-packages\paramiko\transport.py", line 989, in connect
        self.start_client()
      File "C:\DevelopingTools\Python\lib\site-packages\paramiko\transport.py", line 458, in start_client
        raise e
    EOFError

I have googled a lot of hours, tried different version (Arch Linux 64-bit/Windows 7 64-bit, python 2.7 32/64-bit, python 2.6 32-bit, paramiko 1.7.6, pycrypto 2.0.1/2.1/2.2 but nothing helped. I want to program a simple sfpt client for automatic downloading and deleting files but I am really baffled. If anyone could help me I would be very grateful. Thanks.

4

1 回答 1

2

你能试试这个,让我知道它是怎么回事:

ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh.connect("157.178.35.13", username="stackoverflow", password="e2fghK3")
ftp=ssh.open_sftp()
path = './file.testy'    #server
localpath = '/home/iwtu/test' 
ftp.put(localpath, path)
ftp.close()

你的朋友是在 Linux 机器上运行它吗?你是在 Windows 机器上运行它吗?

于 2010-10-07T22:14:10.170 回答