Netmiko: Cisco SG300 series breaking on SSH connection

Created on 28 Jul 2016  ·  9Comments  ·  Source: ktbyers/netmiko

Hello @ktbyers

Thanks for the amazing open source project that NetMiko is. 👍

I would like to get some help on the following issue:

I have a very simple script trying to copy the config of a Cisco SG300 device. My code (I have verbose enabled on Netmiko):

if Device_Model_List[i] == "Cisco":

            #create profile for Juniper for NetMiko
            provision_router_object = {
            'device_type': 'cisco_ios',
            'ip': Public_IP_List[i],
            'username': User_List[i], 
            'password': Password_List[i],
            'port': SSH_Port_List[i],
            'global_delay_factor': 1,
            'verbose': true,
            }

            print(provision_router_object)
            provision_router = ConnectHandler(**provision_router_object)    
            output = provision_router.send_command("show running-config")
            file_name = Name_List[i] + '-' + str(date)
            path = "/Users/sam/Documents/Backup_Router/" + Customer_List[i] + "/" + Customer_Site[i] + "/"
            print(path)
            os.makedirs(os.path.dirname(path), exist_ok=True)

            with open(os.path.join(path,file_name),"w") as file_:
                file_.write(output)   

And here's the verbose + error I am getting:

SSH connection established to 184.68.129.6:2210
Interactive SSH session established

Traceback (most recent call last):
  File "/usr/local/lib/python3.5/site-packages/paramiko/channel.py", line 613, in recv
    out = self.in_buffer.read(nbytes, self.timeout)
  File "/usr/local/lib/python3.5/site-packages/paramiko/buffered_pipe.py", line 160, in read
    raise PipeTimeout()
paramiko.buffered_pipe.PipeTimeout

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.5/site-packages/netmiko/base_connection.py", line 387, in read_until_pattern
    output += self.remote_conn.recv(MAX_BUFFER).decode('utf-8', 'ignore')
  File "/usr/local/lib/python3.5/site-packages/paramiko/channel.py", line 615, in recv
    raise socket.timeout()
socket.timeout

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/sam/Documents/git/OPS/ops/python/router_backup/Backup_Test.py", line 56, in <module>
    provision_router = ConnectHandler(**provision_router_object)  
  File "/usr/local/lib/python3.5/site-packages/netmiko/ssh_dispatcher.py", line 84, in ConnectHandler
    return ConnectionClass(*args, **kwargs)
  File "/usr/local/lib/python3.5/site-packages/netmiko/base_connection.py", line 69, in __init__
    self.session_preparation()
  File "/usr/local/lib/python3.5/site-packages/netmiko/base_connection.py", line 83, in session_preparation
    self.disable_paging()
  File "/usr/local/lib/python3.5/site-packages/netmiko/base_connection.py", line 212, in disable_paging
    output = self.read_until_prompt()
  File "/usr/local/lib/python3.5/site-packages/netmiko/base_connection.py", line 374, in read_until_prompt
    return self.read_until_pattern()
  File "/usr/local/lib/python3.5/site-packages/netmiko/base_connection.py", line 393, in read_until_pattern
    raise NetMikoTimeoutException("Timed-out reading channel, data not available.")
netmiko.ssh_exception.NetMikoTimeoutException: Timed-out reading channel, data not available.

I'm running the latest version of Netmiko and Paramiko. It is working perfect with Juniper devices.

UPDATE: I have tried my script using a truly Cisco IOS device line and it works with no problem. So I believe the issue is the compatibility with the Cisco SG line. I have also tried to make Paramiko works with this Cisco SG device but it hangs on the connection and never times out. Hope this info will help.

Would you have any idea on whaw to try next?

Thank you so much.

Sam.

Netmiko 1_0

All 9 comments

@samulord Yes, SG300 devices are not officially supported.

Can you post what happens during a manual SSH session with your device (stripped of any confidential information i.e. username/password)? In other words, what does the session look like when you manually SSH into it.

Hello @ktbyers

Thanks for the quick answer, please see below how the SSH session looks:

~ ❯❯❯ ssh USERNAME@MYIP -p 2210
The authenticity of host '[MYIP]:2210 ([MYIP]:2210)' can't be established.
RSA key fingerprint is SHA256:5a3hDoagJL7+hWnsxvXwBQgzuOiqx54S6TKQVrI3lFU.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '[MYIP]:2210' (RSA) to the list of known hosts.
USERNAME@MYIP's password:




switchc40ba0#

I have replaced the real username with _USERNAME_ and the real IP with _MYIP_.

Thanks,

Sam.

@samulord How do you disable paging on the SG300? For example, on cisco IOS you do 'terminal length 0'.

From the above stack trace, it looks like it is failing when it tries to disable paging.

Hello @ktbyers

Thanks for your reply.

It looks that on SG300 you can run these commands:

switchc40ba0#terminal
  datadump             Dump all output of a show command without prompting
  history              Enable and control the command history function
  no                   negate the command history function
  prompt               Determine if we want a yes/no prompt.
  width                Set width of the display terminal

I applied terminal history and I was able to get the whole config without the need of pressing space.

I tried to run my script again after using this command, but this is something that you probably need to do in every single session. So I'm assuming NetMiko needs to set this when it logs in?

Thanks again for the help,

Sam.

Will try to get to this in dev_1_0 release (i.e. add support for SG300)

Thanks @ktbyers

Appreciate the help!

Thanks @ktbyers

I will do some testings! Appreciate the help.

Okay, this driver is passing all of the unit tests. Note, you probably need the following configured:

ip ssh password-auth

Kirk

Was this page helpful?
0 / 5 - 0 ratings