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.

Exception while ssh into IOS devices with public keys

See original GitHub issue

Received this exception “paramiko.transport:SSHException: Illegal info request from server” for the following code:

net_device = {
        'device_type': 'cisco_ios',
        'ip': '<REMOVED>',
        'username': '<REMOVED>',
        'use_keys': True,
        'key_file': '<REMOVED>/.ssh/id_rsa',
        'port': 22,
        'allow_agent': True #regardless of value 
}

import netmiko
import logging

logging.basicConfig(level=logging.NOTSET)

net_connect = netmiko.ConnectHandler(**net_device)
show_version = net_connect.send_command('show version')
print show_version

Same code works with JUNOS/NXOS but not with IOS devices.

DEBUG:paramiko.transport:userauth is OK ERROR:paramiko.transport:Exception: Illegal info request from server ERROR:paramiko.transport:Traceback (most recent call last): ERROR:paramiko.transport: File “<REMOVED>/cicd/venv/local/lib/python2.7/site-packages/paramiko/transport.py”, line 1791, in run ERROR:paramiko.transport: self.auth_handler._handler_table[ptype](self.auth_handler, m) ERROR:paramiko.transport: File “<REMOVED>/cicd/venv/local/lib/python2.7/site-packages/paramiko/auth_handler.py”, line 575, in _parse_userauth_info_request ERROR:paramiko.transport: raise SSHException(‘Illegal info request from server’) ERROR:paramiko.transport:SSHException: Illegal info request from server ERROR:paramiko.transport: DEBUG:paramiko.transport:Trying discovered key <REMOVED> in <REMOVED>/.ssh/id_rsa Traceback (most recent call last): File “con_pub.py”, line 17, in <module> net_connect = netmiko.ConnectHandler(**net_device) File “<REMOVED>cicd/venv/local/lib/python2.7/site-packages/netmiko/ssh_dispatcher.py”, line 96, in ConnectHandler return ConnectionClass(*args, **kwargs)

Python 2.7.3 cffi (1.9.1) cryptography (1.6) enum34 (1.1.6) idna (2.1) ipaddress (1.0.17) netmiko (1.1.0) paramiko (2.0.2) pip (9.0.1) pyasn1 (0.1.9) pycparser (2.17) PyYAML (3.12) scp (0.10.2) setuptools (29.0.1) six (1.10.0) wheel (0.29.0)

paramiko_logs.txt Openssh_works_cisco1.25_debug_logs.txt

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:15 (12 by maintainers)

github_iconTop GitHub Comments

3reactions
ktbyerscommented, Dec 8, 2016

@sjtarik I was able to get it working to a Cisco IOS device (Cisco 881) using the following:

#!/usr/bin/env python
from netmiko import ConnectHandler
from getpass import getpass

ip_addr = input("Enter IP Address: ")

device = { 
    'device_type': 'cisco_ios',
    'ip': ip_addr,
    'username': 'testuser',
    'use_keys': True,
    'key_file': '/home/gituser/.ssh/test_rsa',
    'port': 22, 
} 

net_connect = ConnectHandler(**device)
output = net_connect.send_command_expect("show version")
print(output)
0reactions
emma-yemicommented, Mar 7, 2021

What i read here has helped me resolved my issue.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Secure Shell Configuration Guide, Cisco IOS Release 15E
Enables the SSH server for public-key authentication on the device and enters public-key server configuration mode. Step 8, key-string. Example:
Read more >
Public key SSH access - Fortinet Documentation Library
Public -private key pairs can be used to authenticate administrators connecting to the CLI using an SSH client. These keys can be RSA,...
Read more >
Developers - Exception while ssh into IOS devices with public keys -
Received this exception "paramiko.transport:SSHException: Illegal info request from server" for the following code:
Read more >
Public key authentication fails with JSch but work with ...
Test connection in the terminal: ssh -i /path/to/id_rsa username@example.host.com – works fine; Execute the following Kotlin code: import com.
Read more >
# (config ssh-client client-keys) - TechDocs - Broadcom Inc.
subcommand, you create a SSH client key pair: the public key is shared with the remote SSH server, and the private key is...
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