Discussion:
Paramiko hangs
b b
2010-08-08 13:39:25 UTC
Permalink
Hi there,

I was trying to get Paramiko to work on my machine. (Busybox,
Synology) I want to use it as an SFTP client from my other Python
applications.

However, just starting up a transport makes my script hang:

import paramiko
HOST = '192.168.11.11'
tp = paramiko.Transport((HOST, 22))
tp.start_client()

I can't even kill it using C-c. What could be the cause for this? I'm
not seeing this when doing just ssh ***@192.168.11.11

What could be the reason?

I'm using last paramiko checkout.


Thanks

Peter
Eric Noulard
2010-08-08 16:06:42 UTC
Permalink
Post by b b
Hi there,
I was trying to get Paramiko to work on my machine. (Busybox, Synology) I
want to use it as an SFTP client from my other Python applications.
import paramiko
HOST = '192.168.11.11'
tp = paramiko.Transport((HOST, 22))
tp.start_client()
I can't even kill it using C-c. What could be the cause for this? I'm
Is your script hanging during the call to start_client
or later on some code we do not see?
Post by b b
What could be the reason?
Looks to me that you misuse/misundersatnd the API.
your transport object is not authenticated (yet) just after:

tp = paramiko.Transport((HOST, 22))
tp.start_client()
Post by b b
tp.is_active()
True
Post by b b
tp.is_authenticated()
False

after that you need to (from the API doc):
"After a successful negotiation, you will usually want to
authenticate, calling auth_password or auth_publickey."

etc...

I think that may be you use a too low level API for your need.
You may prototype what you want to do using SSHClient

http://www.lag.net/paramiko/docs/paramiko.SSHClient-class.html

from which you can get an SFTPClient:

client = paramiko.SSHClient()
client.load_system_host_keys()
client.connect('192.168.11.11')
sftp = client.open_sftp()

then you have the sftp object to work with doing
get/put etc...

I may be wrong, may be you already tried the high level tests
and decided to go low-level after that.
--
Erk
Membre de l'April - « promouvoir et défendre le logiciel libre » -
http://www.april.org
b b
2010-08-08 18:13:52 UTC
Permalink
Hi,
thanks for your answer.
I tried couple of examples from internet, also with authentication with
password and also with rsa. In every example it hangs. I tried what you
Post by b b
import paramiko
RandomPool_DeprecationWarning: This application uses RandomPool, which is
BROKEN in older releases. See http://www.pycrypto.org/randpool-broken
RandomPool_DeprecationWarning)
Post by b b
client = paramiko.SSHClient()
client.load_system_host_keys()
client.connect('192.168.11.11')
now it hangs
You should at least put a username in your connect statement.
yes that's correct, but there is no change if I use username and password,
it hangs on the same position
This may work if you are using agent based + public authentication.
If not then you must add a password or explicit public key.
http://segfault.in/2010/03/paramiko-ssh-and-sftp-with-python/
http://code.activestate.com/recipes/576810-copy-files-over-ssh-using-paramiko/
http://commandline.org.uk/python/sftp-python/
But those example are using username and either passwd or public key
and your example does not show you are.
I have no idea, what the problem is. I get no exception, no error or
traceback. It just hangs...
Are you running a script or are doing you test interactively?
interactively, but I tried also as a script, with no success
The "hang" you see may be due to paramiko's background thread
that would be probably my case, after I kill my python with ctrl+z and do
ps I can see some python processes running
I have now the latest revision installed.
Should I try it not interactively but instead as a script? From that threat
it's not so clear for me what should I do.
But I already tried it also as a script and it didn't help.
I'm little bit confused....

Thanks for your help.
PS: please keep cc the list, that way others may get a chance to answer
your question as well.
--
Erk
Membre de l'April - « promouvoir et défendre le logiciel libre » -
http://www.april.org
Eric Noulard
2010-08-08 20:19:36 UTC
Permalink
This post might be inappropriate. Click to display it.
b b
2010-08-08 20:33:09 UTC
Permalink
This post might be inappropriate. Click to display it.
Eric Noulard
2010-08-08 16:54:25 UTC
Permalink
Hi,
thanks for your answer.
I tried couple of examples from internet, also with authentication with
password and also with rsa. In every example it hangs. I tried what you
Post by b b
import paramiko
RandomPool_DeprecationWarning: This application uses RandomPool, which is
BROKEN in older releases.  See http://www.pycrypto.org/randpool-broken
  RandomPool_DeprecationWarning)
Post by b b
client = paramiko.SSHClient()
client.load_system_host_keys()
client.connect('192.168.11.11')
now it hangs
You should at least put a username in your connect statement.

This may work if you are using agent based + public authentication.
If not then you must add a password or explicit public key.
http://segfault.in/2010/03/paramiko-ssh-and-sftp-with-python/
http://code.activestate.com/recipes/576810-copy-files-over-ssh-using-paramiko/
http://commandline.org.uk/python/sftp-python/
But those example are using username and either passwd or public key
and your example does not show you are.
I have no idea, what the problem is. I get no exception, no error or
traceback. It just hangs...
Are you running a script or are doing you test interactively?
The "hang" you see may be due to paramiko's background thread
preventing the termination of the python interpreter:
cf http://www.mail-archive.com/***@lag.net/msg00373.html

PS: please keep cc the list, that way others may get a chance to answer
your question as well.
--
Erk
Membre de l'April - « promouvoir et défendre le logiciel libre » -
http://www.april.org
Loading...