views:

123

answers:

1

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.

+2  A: 

Can you try this and let me know how it goes:

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()

Is your friend running it on a Linux box? Are you running it on a Windows machine?

fixxxer
>>> ssh = paramiko.SSHClient()>>> ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())>>> ssh.connect("195.168.25.134", username="pehacom", password="e3fys3ZL")Traceback (most recent call last): File "<pyshell#9>", line 1, in <module> ssh.connect("175.161.15.177", username="stackoverflow", password="e3fys3ZL") File "C:\DevelopingTools\Python\lib\site-packages\paramiko\client.py", line 291, in connect sock.connect(addr) File "<string>", line 1, in connecterror: [Errno 10061] No connection could be made because the target machine actively refused it
iwtu
I need the aplication for Windows OS whare I have problem of use pycrypto. My friend has gentoo.
iwtu
@iwtu - The output that you have pasted shows that machine wasn't allowing any connections to happen! Try the code on another machine. And if you want to delete files at a remote system, you can append this code below the ftp.close() in my comment : ssh.exec_command("<insert-command>")<insert-command> - is the command that you want the remote command to execute for you.
fixxxer
@iwtu - what problem are you facing with PyCrypto? Is "import paramiko" causing you an error?
fixxxer