paramiko
Guilherme Polo
ggpolo at gmail.com
Wed Jan 16 12:11:36 EST 2008
2008/1/16, Tarun Kapoor <tkapoor at wscm.net>:
>
>
>
>
> I am using paramiko to do an SFTP file transfer… I was able to connect to
> the remote server using an SFTP client I have just to make sure that
> username and password are working.. This is the code.
>
>
>
> # now, connect and use paramiko Transport to negotiate SSH2 across the
> connection
>
> sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
>
> sock.connect((hostname, port))
>
>
>
> t = paramiko.Transport(sock)
>
> event = threading.Event()
>
> t.start_client(event)
>
>
>
> event.wait(15)
>
>
>
> if not t.is_active():
>
> print 'SSH negotiation failed.'
>
> sys.exit(1)
>
> else:
>
> print "SSH negotiation sucessful"
>
>
>
> event.clear()
>
>
>
> t.auth_password(username=username, password=password,event=event)
>
>
>
> if not t.is_authenticated():
>
> print "not authenticated"
>
> output:
>
> SSH negotiation successful
>
> not authenticated
>
>
>
>
>
>
>
> Tarun
>
>
>
> Waterstone Capital Management
>
> 2 Carlson Parkway, Suite 260
>
> Plymouth, MN 55447
>
>
>
> Direct: 952-697-4123
>
> Cell: 612-205-2587
> Disclaimer This e-mail and any attachments is confidential and intended
> solely for the use of the individual(s) to whom it is addressed. Any views
> or opinions presented are solely those of the author and do not necessarily
> represent those of Waterstone Capital Management, L.P and affiliates. If you
> are not the intended recipient, be advised that you have received this
> e-mail in error and that any use, dissemination, printing, forwarding or
> copying of this email is strictly prohibited. Please contact the sender if
> you have received this e-mail in error. You should also be aware that
> e-mails are susceptible to interference and you should not assume that the
> contents of this e-mail originated from the sender above or that they have
> been accurately reproduced in their original form. Waterstone Capital
> Management, L.P. and affiliates accepts no responsibility for information,
> or errors or omissions in this e-mail or use or misuse thereof. If in doubt,
> please verify the authenticity with the sender.
> --
> http://mail.python.org/mailman/listinfo/python-list
>
You are missing an event.wait() after t.auth_password.
Also, why are you passing this magic value "15" to event.wait() ? That
parameter is passed to class _Verbose to indicate if debug messages
should be displayed or not, so typical values would be 0/1 or
False/True.
--
-- Guilherme H. Polo Goncalves
More information about the Python-list
mailing list