question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cisco 3560 SSH problem "paramiko.ssh_exception.SSHException: No existing session"

See original GitHub issue

I have problem to connect to Cisco catalyst 3560 switch using Napalm:

>>> from netmiko import ConnectHandler
>>> from napalm import get_network_driver
>>> get_network_driver('ios')
<class 'napalm_ios.ios.IOSDriver'>
>>> driver = get_network_driver('ios')
>>> device = driver('<REMOVED>', '<REMOVED>', '<REMOVED>')
>>> device.open()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/jaakkorau/ansible-env/lib/python2.7/site-packages/napalm_ios/ios.py", line 116, in open
    **self.netmiko_optional_args)
  File "/home/jaakkorau/ansible-env/lib/python2.7/site-packages/netmiko/ssh_dispatcher.py", line 105, in ConnectHandler
    return ConnectionClass(*args, **kwargs)
  File "/home/jaakkorau/ansible-env/lib/python2.7/site-packages/netmiko/base_connection.py", line 144, in __init__
    self.establish_connection()
  File "/home/jaakkorau/ansible-env/lib/python2.7/site-packages/netmiko/base_connection.py", line 468, in establish_connection
    self.remote_conn_pre.connect(**ssh_connect_params)
  File "/home/jaakkorau/ansible-env/lib/python2.7/site-packages/paramiko/client.py", line 341, in connect
    server_key = t.get_remote_server_key()
  File "/home/jaakkorau/ansible-env/lib/python2.7/site-packages/paramiko/transport.py", line 670, in get_remote_server_key
    raise SSHException('No existing session')
paramiko.ssh_exception.SSHException: No existing session

Manual SSH enforced to version 2 works well. Output of show ip ssh is below:

SSH Enabled - version 2.0
Authentication methods:publickey,keyboard-interactive,password
Encryption Algorithms:aes128-ctr,aes192-ctr,aes256-ctr,aes128-cbc,3des-cbc,aes192-cbc,aes256-cbc
MAC Algorithms:hmac-sha1,hmac-sha1-96
Authentication timeout: 120 secs; Authentication retries: 3
Minimum expected Diffie Hellman key size : 1024 bits
IOS Keys in SECSH format(ssh-rsa, base64 encoded):
ssh-rsa <KEY_REMOVED>

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:31 (14 by maintainers)

github_iconTop GitHub Comments

1reaction
filintodcommented, Nov 10, 2017

@ktbyers I was using paramiko straight not via netmiko but was looking for a solution to this problem NoExistingSession (same method get_remote_server_key) and the solution at the end was to increase the timeout when connecting. So I thought that maybe they could try with an extended timeout to see if that also solved their problem.

0reactions
toghraeecommented, Mar 19, 2018

Normally after Kex, Cipher , MAC and compression agreement in the log you should see a User authentication (userauth) log. (refer to my logs in this thread) .

Also I noticed that Paramiko is not throwing any exception.

I suggest to trace the parameters sent to paramiko , I think there is something missing, i.e the user authentication paramaters not passed.

Another simple test to isolate the problem will be to use the your program and try to connect to a standard Linux host, check if SSH connection can get established or not.

Best Regards

Reza Toghraee

From: princedhadwal [mailto:notifications@github.com] Sent: 19 March 2018 11:13 To: ktbyers/netmiko netmiko@noreply.github.com Cc: Reza Toghraee reza@toghraee.com; Mention mention@noreply.github.com Subject: Re: [ktbyers/netmiko] Cisco 3560 SSH problem “paramiko.ssh_exception.SSHException: No existing session” (#467)

Below are the paramiko logs

DEBUG:my_log:This message should go to the log file DEBUG:my_log:This message should go to the log file DEBUG:my_log:This message should go to the log file DEBUG:paramiko.transport:starting thread (client mode): 0x30ab250L DEBUG:paramiko.transport:Local version/idstring: SSH-2.0-paramiko_2.3.1 DEBUG:paramiko.transport:Remote version/idstring: SSH-2.0-OpenSSH_6.7p1 Debian-5+deb8u1 INFO:paramiko.transport:Connected (version 2.0, client OpenSSH_6.7p1) DEBUG:paramiko.transport:kex algos:[u’curve25519-sha256@libssh.org’, u’ecdh-sha2-nistp256’, u’ecdh-sha2-nistp384’, u’ecdh-sha2-nistp521’, u’diffie-hellman-group-exchange-sha256’, u’diffie-hellman-group14-sha1’] server key:[u’ssh-rsa’, u’ssh-dss’, u’ecdsa-sha2-nistp256’, u’ssh-ed25519’] client encrypt:[u’aes128-ctr’, u’aes192-ctr’, u’aes256-ctr’, u’aes128-gcm@openssh.com’, u’aes256-gcm@openssh.com’, u’chacha20-poly1305@openssh.com’] server encrypt:[u’aes128-ctr’, u’aes192-ctr’, u’aes256-ctr’, u’aes128-gcm@openssh.com’, u’aes256-gcm@openssh.com’, u’chacha20-poly1305@openssh.com’] client mac:[u’umac-64-etm@openssh.com’, u’umac-128-etm@openssh.com’, u’hmac-sha2-256-etm@openssh.com’, u’hmac-sha2-512-etm@openssh.com’, u’hmac-sha1-etm@openssh.com’, u’umac-64@openssh.com’, u’umac-128@openssh.com’, u’hmac-sha2-256’, u’hmac-sha2-512’, u’hmac-sha1’] server mac:[u’umac-64-etm@openssh.com’, u’umac-128-etm@openssh.com’, u’hmac-sha2-256-etm@openssh.com’, u’hmac-sha2-512-etm@openssh.com’, u’hmac-sha1-etm@openssh.com’, u’umac-64@openssh.com’, u’umac-128@openssh.com’, u’hmac-sha2-256’, u’hmac-sha2-512’, u’hmac-sha1’] client compress:[u’none’, u’zlib@openssh.com’] server compress:[u’none’, u’zlib@openssh.com’] client lang:[u’‘] server lang:[u’'] kex follows?False DEBUG:paramiko.transport:Kex agreed: ecdh-sha2-nistp256 DEBUG:paramiko.transport:HostKey agreed: ssh-ed25519 DEBUG:paramiko.transport:Cipher agreed: aes128-ctr DEBUG:paramiko.transport:MAC agreed: hmac-sha2-256 DEBUG:paramiko.transport:Compression agreed: none DEBUG:paramiko.transport:EOF in transport thread

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/ktbyers/netmiko/issues/467#issuecomment-374177599 , or mute the thread https://github.com/notifications/unsubscribe-auth/ACPIp3Hqpxioh9JR_c7UTfjGBxW5Ec6qks5tf5LHgaJpZM4NYUr1 .

Read more comments on GitHub >

github_iconTop Results From Across the Web

Python paramiko.ssh_exception.SSHException: No existing ...
The code works for me. I get error in auth_password too (though different – "Authentication failed"), when I have a key loaded in...
Read more >
Incompatible version (2.99 instead of 2.0) - Cisco Community
I have no issue SSH manually from Linux client to Cisco Router. ... raise SSHException(msg.format(version)) paramiko.ssh_exception.
Read more >
A brand new website interface for an even better experience!
Cisco 3560 SSH problem "paramiko.ssh_exception.SSHException: No existing session"
Read more >
The Python Paramiko library - Packt Subscription
Paramiko is the low-level SSH client behind the high-level automation framework ... raise SSHException('SSH session not active') paramiko.ssh_exception.
Read more >
Python SSH - NetworkLessons.com Community Forum
In order to implement more commands in a single session, you simply input them in a ... SSHException: No authentication methods available.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found