From: George Trojan on 19 Jul 2010 16:06 I have a problem with connecting to a host without specifying password (but with ssh keys configured correctly. That is [tina src]$ sftp alice Connecting to alice... sftp> works, but the code import paramiko paramiko.util.log_to_file('/tmp/paramiko') t = paramiko.Transport(('alice', 22)) t.connect(username='gtrojan') # , password='a-passwd']) sftp = paramiko.SFTPClient.from_transport(t) sftp.close() t.close() results in the following output in /tmp/paramiko: DEB [20100719-19:58:22.497] thr=1 paramiko.transport: starting thread (client mode): 0xb81e1150L INF [20100719-19:58:22.501] thr=1 paramiko.transport: Connected (version 2.0, client OpenSSH_4.3) DEB [20100719-19:58:22.502] thr=1 paramiko.transport: kex algos:['diffie-hellman-group-exchange-sha1', 'diffie-hellman-group14-sha1', 'diffie-hellman-group1-sha1'] server key:['ssh-rsa', 'ssh-dss'] client encrypt:['aes128-cbc', '3des-cbc', 'blowfish-cbc', 'cast128-cbc', 'arcfour128', 'arcfour256', 'arcfour', 'aes192-cbc', 'aes256-cbc', 'rijndael-cbc(a)lysator.liu.se', 'aes128-ctr', 'aes192-ctr', 'aes256-ctr'] server encrypt:['aes128-cbc', '3des-cbc', 'blowfish-cbc', 'cast128-cbc', 'arcfour128', 'arcfour256', 'arcfour', 'aes192-cbc', 'aes256-cbc', 'rijndael-cbc(a)lysator.liu.se', 'aes128-ctr', 'aes192-ctr', 'aes256-ctr'] client mac:['hmac-md5', 'hmac-sha1', 'hmac-ripemd160', 'hmac-ripemd160(a)openssh.com', 'hmac-sha1-96', 'hmac-md5-96'] server mac:['hmac-md5', 'hmac-sha1', 'hmac-ripemd160', 'hmac-ripemd160(a)openssh.com', 'hmac-sha1-96', 'hmac-md5-96'] client compress:['none', 'zlib(a)openssh.com'] server compress:['none', 'zlib(a)openssh.com'] client lang:[''] server lang:[''] kex follows?False DEB [20100719-19:58:22.502] thr=1 paramiko.transport: Ciphers agreed: local=aes128-ctr, remote=aes128-ctr DEB [20100719-19:58:22.502] thr=1 paramiko.transport: using kex diffie-hellman-group1-sha1; server key type ssh-rsa; cipher: local aes128-ctr, remote aes128-ctr; mac: local hmac-sha1, remote hmac-sha1; compression: local none, remote none DEB [20100719-19:58:22.571] thr=1 paramiko.transport: Switch to new keys ... DEB [20100719-19:58:22.578] thr=2 paramiko.transport: [chan 1] Max packet in: 34816 bytes WAR [20100719-19:58:22.611] thr=1 paramiko.transport: Oops, unhandled type 3 DEB [20100719-20:00:22.502] thr=1 paramiko.transport: EOF in transport thread and a traceback in the terminal: Traceback (most recent call last): File "./try.py", line 18, in <module> sftp = paramiko.SFTPClient.from_transport(t) File "build/bdist.linux-x86_64/egg/paramiko/sftp_client.py", line 102, in from_transport File "build/bdist.linux-x86_64/egg/paramiko/transport.py", line 655, in open_session File "build/bdist.linux-x86_64/egg/paramiko/transport.py", line 745, in open_channel EOFError When the remove the comment on the connect() line and specify password the code works fine. Is this a bug, or I am missing something? I am running Python 2.6.3 on Centos 5.4. George
From: George Trojan on 19 Jul 2010 17:02 George Trojan wrote: > I have a problem with connecting to a host without specifying password > (but with ssh keys configured correctly. That is > > [tina src]$ sftp alice > Connecting to alice... > sftp> > > works, but the code > > import paramiko > paramiko.util.log_to_file('/tmp/paramiko') > t = paramiko.Transport(('alice', 22)) > t.connect(username='gtrojan') # , password='a-passwd']) > sftp = paramiko.SFTPClient.from_transport(t) > sftp.close() > t.close() > > results in the following output in /tmp/paramiko: > > DEB [20100719-19:58:22.497] thr=1 paramiko.transport: starting thread > (client mode): 0xb81e1150L > INF [20100719-19:58:22.501] thr=1 paramiko.transport: Connected > (version 2.0, client OpenSSH_4.3) > DEB [20100719-19:58:22.502] thr=1 paramiko.transport: kex > algos:['diffie-hellman-group-exchange-sha1', > 'diffie-hellman-group14-sha1', 'diffie-hellman-group1-sha1'] server > key:['ssh-rsa', 'ssh-dss'] client encrypt:['aes128-cbc', '3des-cbc', > 'blowfish-cbc', 'cast128-cbc', 'arcfour128', 'arcfour256', 'arcfour', > 'aes192-cbc', 'aes256-cbc', 'rijndael-cbc(a)lysator.liu.se', 'aes128-ctr', > 'aes192-ctr', 'aes256-ctr'] server encrypt:['aes128-cbc', '3des-cbc', > 'blowfish-cbc', 'cast128-cbc', 'arcfour128', 'arcfour256', 'arcfour', > 'aes192-cbc', 'aes256-cbc', 'rijndael-cbc(a)lysator.liu.se', 'aes128-ctr', > 'aes192-ctr', 'aes256-ctr'] client mac:['hmac-md5', 'hmac-sha1', > 'hmac-ripemd160', 'hmac-ripemd160(a)openssh.com', 'hmac-sha1-96', > 'hmac-md5-96'] server mac:['hmac-md5', 'hmac-sha1', 'hmac-ripemd160', > 'hmac-ripemd160(a)openssh.com', 'hmac-sha1-96', 'hmac-md5-96'] client > compress:['none', 'zlib(a)openssh.com'] server compress:['none', > 'zlib(a)openssh.com'] client lang:[''] server lang:[''] kex follows?False > DEB [20100719-19:58:22.502] thr=1 paramiko.transport: Ciphers agreed: > local=aes128-ctr, remote=aes128-ctr > DEB [20100719-19:58:22.502] thr=1 paramiko.transport: using kex > diffie-hellman-group1-sha1; server key type ssh-rsa; cipher: local > aes128-ctr, remote aes128-ctr; mac: local hmac-sha1, remote hmac-sha1; > compression: local none, remote none > DEB [20100719-19:58:22.571] thr=1 paramiko.transport: Switch to new > keys ... > DEB [20100719-19:58:22.578] thr=2 paramiko.transport: [chan 1] Max > packet in: 34816 bytes > WAR [20100719-19:58:22.611] thr=1 paramiko.transport: Oops, unhandled > type 3 > DEB [20100719-20:00:22.502] thr=1 paramiko.transport: EOF in transport > thread > > and a traceback in the terminal: > > Traceback (most recent call last): > File "./try.py", line 18, in <module> > sftp = paramiko.SFTPClient.from_transport(t) > File "build/bdist.linux-x86_64/egg/paramiko/sftp_client.py", line 102, > in from_transport > File "build/bdist.linux-x86_64/egg/paramiko/transport.py", line 655, > in open_session > File "build/bdist.linux-x86_64/egg/paramiko/transport.py", line 745, > in open_channel > EOFError > > When the remove the comment on the connect() line and specify password > the code works fine. Is this a bug, or I am missing something? I am > running Python 2.6.3 on Centos 5.4. > > George Thanks for listening;-) Found my problem - has to pass private key to connect(): paramiko.util.log_to_file('/tmp/paramiko') t = paramiko.Transport(('alice', 22)) path = os.path.join(os.environ['HOME'], '.ssh', 'id_dsa') key = paramiko.DSSKey.from_private_key_file(path) t.connect(username='gtrojan', pkey=key) sftp = paramiko.SFTPClient.from_transport(t) print sftp.listdir() sftp.close() t.close()
|
Pages: 1 Prev: CPython Signal Handler Check for SIGKILL Next: How to pass the shell in Python |