Re: paramiko



# 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)
t.start_client()
key = t.get_remote_server_key()

event = threading.Event()
t.auth_password(username=username, password=password, event=event)
event.wait()

if not t.is_authenticated():
print "not authenticated"

output:
not authenticated




On Jan 16, 11:11 am, "Guilherme Polo" <ggp...@xxxxxxxxx> wrote:
2008/1/16, Tarun Kapoor <tkap...@xxxxxxxx>:





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

.



Relevant Pages

  • Re: paramiko
    ... the connection ... contents of this e-mail originated from the sender above or that they have ... please verify the authenticity with the sender. ... -- Guilherme H. Polo Goncalves ...
    (comp.lang.python)
  • Re: paramiko
    ... the connection ... contents of this e-mail originated from the sender above or that they have ... please verify the authenticity with the sender. ... -- Guilherme H. Polo Goncalves ...
    (comp.lang.python)
  • Re: Processs PreciseMail AntiSpam Gateway - any experience so far ?
    ... >> before closing the connection. ... Instead you have the sender picking the port ... if the receiver ESP can make that work. ...
    (comp.os.vms)
  • Re: Nochmals Treeview
    ... private void button1_Click(object sender, System.EventArgs e) { ... private void TabelleAnlegen(string strDBPfad, string strDB, string strTabellenName){ ... OleDbConnection connection = new OleDbConnection; ... OleDbCommand command = new OleDbCommand; ...
    (microsoft.public.de.german.entwickler.dotnet.csharp)
  • Woody Sendmail: blacklist_recipients feature not working
    ... Normal mail delivery is working, but I can't get the "blacklist_recipients" ... # Test sender rejection - works OK ... # Test recipient rejection - doesn't work ... Connection closed by foreign host. ...
    (Debian-User)