ubuntu 11.10 desktop: paramiko.SSHException: No existing session

Bug #912123 reported by wang yang
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
paramiko
New
Undecided
Unassigned

Bug Description

https://answers.launchpad.net/ubuntu/+source/paramiko/+question/183769

if user is not root, and use "ssh.connect(xxxx, username=xxxx, password=xxxx)", it always report exception: "paramiko.SSHException: No existing session". through debug, can find it failed because access agent, so disable agent can work: "ssh.connect(xxxx, username=xxxx, password=xxxx, allow_agent=False)"

python ssh_test.py

*INFO* Logging into '10.56.117.82:22' as 'root'.
Traceback (most recent call last):
  File "ssh_test.py", line 22, in <module>
    main()
  File "ssh_test.py", line 14, in main
    ssh.login(user, passwd)
  File "/usr/local/lib/python2.7/dist-packages/SSHLibrary/__init__.py", line 193, in login
    self._client.login(username, password)
  File "/usr/local/lib/python2.7/dist-packages/SSHLibrary/pythonclient.py", line 46, in login
    self.client.connect(self.host, self.port, username, password)
  File "build/bdist.linux-i686/egg/paramiko/client.py", line 332, in connect
  File "build/bdist.linux-i686/egg/paramiko/client.py", line 493, in _auth

DEBUG:paramiko.transport:starting thread (client mode): 0x919a1ccL
INFO:paramiko.transport:Connected (version 2.0, client OpenSSH_4.3)
DEBUG: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-ctr', 'aes192-ctr', 'aes256-ctr', 'arcfour256', 'arcfour128', 'aes128-cbc', '3des-cbc', 'blowfish-cbc', 'cast128-cbc', 'aes192-cbc', 'aes256-cbc', 'arcfour', '<email address hidden>'] server encrypt:['aes128-ctr', 'aes192-ctr', 'aes256-ctr', 'arcfour256', 'arcfour128', 'aes128-cbc', '3des-cbc', 'blowfish-cbc', 'cast128-cbc', 'aes192-cbc', 'aes256-cbc', 'arcfour', '<email address hidden>'] client mac:['hmac-md5', 'hmac-sha1', 'hmac-ripemd160', '<email address hidden>', 'hmac-sha1-96', 'hmac-md5-96'] server mac:['hmac-md5', 'hmac-sha1', 'hmac-ripemd160', '<email address hidden>', 'hmac-sha1-96', 'hmac-md5-96'] client compress:['none', '<email address hidden>'] server compress:['none', '<email address hidden>'] client lang:[''] server lang:[''] kex follows?False
DEBUG:paramiko.transport:Ciphers agreed: local=aes128-ctr, remote=aes128-ctr
DEBUG: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
DEBUG:paramiko.transport:Switch to new keys ...
DEBUG:paramiko.transport:Adding ssh-rsa host key for 10.56.117.82: 36a9604e78384576455244088b688c0a
DEBUG:paramiko.transport:Trying SSH agent key 94fb43f4fcab28b992cc3f07ecbd1484
DEBUG:paramiko.transport:userauth is OK
ERROR:paramiko.transport:Exception: key cannot be used for signing
ERROR:paramiko.transport:Traceback (most recent call last):
ERROR:paramiko.transport: File "build/bdist.linux-i686/egg/paramiko/transport.py", line 1559, in run
ERROR:paramiko.transport: self.auth_handler._handler_table[ptype](self.auth_handler, m)
ERROR:paramiko.transport: File "build/bdist.linux-i686/egg/paramiko/auth_handler.py", line 209, in _parse_service_accept
ERROR:paramiko.transport: sig = self.private_key.sign_ssh_data(self.transport.rng, blob)
ERROR:paramiko.transport: File "build/bdist.linux-i686/egg/paramiko/agent.py", line 152, in sign_ssh_data
ERROR:paramiko.transport: raise SSHException('key cannot be used for signing')
ERROR:paramiko.transport:SSHException: key cannot be used for signing
ERROR:paramiko.transport:
Traceback (most recent call last):
  File "test.py", line 19, in <module>
    main()
  File "test.py", line 8, in main
    ssh.connect(ip_addr, username=user, password=passwd)
  File "build/bdist.linux-i686/egg/paramiko/client.py", line 332, in connect
  File "build/bdist.linux-i686/egg/paramiko/client.py", line 493, in _auth
paramiko.SSHException: No existing session

Revision history for this message
wang yang (wang-yang1980) wrote :

i checked paramiko, in agent.py

     self.conn = None
 59 self.keys = ()
 60 if ('SSH_AUTH_SOCK' in os.environ) and (sys.platform != 'win32'):
 61 conn = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
 62 try:
 63 conn.connect(os.environ['SSH_AUTH_SOCK'])
 64 except:
 65 # probably a dangling env var: the ssh agent is gone
 66 return
 67 self.conn = conn
 68 elif sys.platform == 'win32':
 69 import win_pageant
 70 if win_pageant.can_talk_to_agent():
 71 self.conn = win_pageant.PageantConnection()
 72 else:
 73 return

it will use SSH_AUTH_SOCK envrionment variable when through auth_publickey
SSH_AUTH_SOCK=/tmp/keyring-2bBsGe/ssh

for root user, has no such envrionment variable, so it is ok.
if i add, it will fail too.

Revision history for this message
wang yang (wang-yang1980) wrote :

y136wang@y136wang-VirtualBox:~/work/Eclipse_workspace/python_test/src$ export SSH_AUTH_SOCK=/tmp/ssh-aqGtVuyQ1583/agent.1583
y136wang@y136wang-VirtualBox:~/work/Eclipse_workspace/python_test/src$ python test.py
out: /root

err:
y136wang@y136wang-VirtualBox:~/work/Eclipse_workspace/python_test/src$ export SSH_AUTH_SOCK=/tmp/keyring-2bBsGe/ssh
y136wang@y136wang-VirtualBox:~/work/Eclipse_workspace/python_test/src$ python test.py
No handlers could be found for logger "paramiko.transport"
Traceback (most recent call last):
  File "test.py", line 20, in <module>
    main()
  File "test.py", line 9, in main
    ssh.connect(ip_addr, username=user, password=passwd)
  File "build/bdist.linux-i686/egg/paramiko/client.py", line 332, in connect
  File "build/bdist.linux-i686/egg/paramiko/client.py", line 493, in _auth
paramiko.SSHException: No existing session
y136wang@y136wang-VirtualBox:~/work/Eclipse_workspace/python_test/src$

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.