<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Use Cisco Router as a jump host with Python (for SSH and Telnet) in Controllers</title>
    <link>https://community.cisco.com/t5/controllers/use-cisco-router-as-a-jump-host-with-python-for-ssh-and-telnet/m-p/4043411#M1967</link>
    <description>&lt;P&gt;I have a scenario where I need to connect to many remote Cisco devices to run commands via Python script. These remote Cisco devices are not directly accessible from where I have Python scripts running so I am going to have to connect via an intermediate Router first (use the Cisco router it as a Jump host to connect to the remote Cisco devices) I found a python module for SSH (jumpssh:&amp;nbsp;&lt;A href="https://pypi.org/project/jumpssh/" target="_blank" rel="noopener"&gt;https://pypi.org/project/jumpssh/&lt;/A&gt;)&amp;nbsp; but I need one that supports SSH as well as Telnet. Or is there a similar module for Python that I can use for Telnet?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Topology:&lt;/P&gt;&lt;P&gt;Python Server------------------&amp;gt; Cisco Router -----------------------&amp;gt; Remote Cisco Devices&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have had quite a detailed search for this and can't find an obvious answer to this.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm even having problems with the jumpssh module as it's throwing an error (ChannelException(3, 'Unknown channel type') Which makes me think it's not designed to be using a Router as a jump host, it is probably expecting a proper *nix machine.&lt;/P&gt;&lt;P&gt;Any help appreciated.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 10 Mar 2020 12:25:03 GMT</pubDate>
    <dc:creator>velo84</dc:creator>
    <dc:date>2020-03-10T12:25:03Z</dc:date>
    <item>
      <title>Use Cisco Router as a jump host with Python (for SSH and Telnet)</title>
      <link>https://community.cisco.com/t5/controllers/use-cisco-router-as-a-jump-host-with-python-for-ssh-and-telnet/m-p/4043411#M1967</link>
      <description>&lt;P&gt;I have a scenario where I need to connect to many remote Cisco devices to run commands via Python script. These remote Cisco devices are not directly accessible from where I have Python scripts running so I am going to have to connect via an intermediate Router first (use the Cisco router it as a Jump host to connect to the remote Cisco devices) I found a python module for SSH (jumpssh:&amp;nbsp;&lt;A href="https://pypi.org/project/jumpssh/" target="_blank" rel="noopener"&gt;https://pypi.org/project/jumpssh/&lt;/A&gt;)&amp;nbsp; but I need one that supports SSH as well as Telnet. Or is there a similar module for Python that I can use for Telnet?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Topology:&lt;/P&gt;&lt;P&gt;Python Server------------------&amp;gt; Cisco Router -----------------------&amp;gt; Remote Cisco Devices&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have had quite a detailed search for this and can't find an obvious answer to this.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm even having problems with the jumpssh module as it's throwing an error (ChannelException(3, 'Unknown channel type') Which makes me think it's not designed to be using a Router as a jump host, it is probably expecting a proper *nix machine.&lt;/P&gt;&lt;P&gt;Any help appreciated.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 10 Mar 2020 12:25:03 GMT</pubDate>
      <guid>https://community.cisco.com/t5/controllers/use-cisco-router-as-a-jump-host-with-python-for-ssh-and-telnet/m-p/4043411#M1967</guid>
      <dc:creator>velo84</dc:creator>
      <dc:date>2020-03-10T12:25:03Z</dc:date>
    </item>
    <item>
      <title>Re: Use Cisco Router as a jump host with Python (for SSH and Telnet)</title>
      <link>https://community.cisco.com/t5/controllers/use-cisco-router-as-a-jump-host-with-python-for-ssh-and-telnet/m-p/4043824#M1968</link>
      <description>&lt;P&gt;Hi velo84,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;NetMiko is a python Library that can use either SSH, Telnet or Serial Cable to connect a device. Have a look at the documentation &lt;A href="https://pynet.twb-tech.com/blog/automation/netmiko.html" target="_blank" rel="noopener"&gt;here&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I hope this helps!&lt;/P&gt;</description>
      <pubDate>Wed, 11 Mar 2020 00:44:35 GMT</pubDate>
      <guid>https://community.cisco.com/t5/controllers/use-cisco-router-as-a-jump-host-with-python-for-ssh-and-telnet/m-p/4043824#M1968</guid>
      <dc:creator>LanDownUnda</dc:creator>
      <dc:date>2020-03-11T00:44:35Z</dc:date>
    </item>
    <item>
      <title>Re: Use Cisco Router as a jump host with Python (for SSH and Telnet)</title>
      <link>https://community.cisco.com/t5/controllers/use-cisco-router-as-a-jump-host-with-python-for-ssh-and-telnet/m-p/4044026#M1969</link>
      <description>&lt;P&gt;Thanks for that. I have actually written scripts with Netmiko before and it's worked well. It's also what I have been currently using to try and get this working.&amp;nbsp;This is slightly different to the normal Netmiko implementation though, I am connecting to remote devices running telnet through an existing Netmiko SSH session via a intermediate router.&lt;/P&gt;</description>
      <pubDate>Wed, 11 Mar 2020 09:01:16 GMT</pubDate>
      <guid>https://community.cisco.com/t5/controllers/use-cisco-router-as-a-jump-host-with-python-for-ssh-and-telnet/m-p/4044026#M1969</guid>
      <dc:creator>velo84</dc:creator>
      <dc:date>2020-03-11T09:01:16Z</dc:date>
    </item>
    <item>
      <title>Re: Use Cisco Router as a jump host with Python (for SSH and Telnet)</title>
      <link>https://community.cisco.com/t5/controllers/use-cisco-router-as-a-jump-host-with-python-for-ssh-and-telnet/m-p/4044040#M1970</link>
      <description>&lt;P&gt;Would you have much luck by nesting the telnet session within the SSH connection that NetMiko is giving you?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For example:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;net_connect = Netmiko(**cisco1)&lt;BR /&gt;command = "telnet 192.168.1.1"&lt;BR /&gt;telnetusername = "cisco"&lt;BR /&gt;telnetpassword = "cisco"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;print()&lt;/P&gt;&lt;P&gt;print(net_connect.find_prompt())&lt;BR /&gt;output = net_connect.send_command(command)&lt;BR /&gt;output1 = net_connect.send_command(telnetusername)&lt;BR /&gt;output2 = net_connect.send_command(telnetpassword)&lt;/P&gt;</description>
      <pubDate>Wed, 11 Mar 2020 09:20:41 GMT</pubDate>
      <guid>https://community.cisco.com/t5/controllers/use-cisco-router-as-a-jump-host-with-python-for-ssh-and-telnet/m-p/4044040#M1970</guid>
      <dc:creator>LanDownUnda</dc:creator>
      <dc:date>2020-03-11T09:20:41Z</dc:date>
    </item>
    <item>
      <title>Re: Use Cisco Router as a jump host with Python (for SSH and Telnet)</title>
      <link>https://community.cisco.com/t5/controllers/use-cisco-router-as-a-jump-host-with-python-for-ssh-and-telnet/m-p/4044061#M1971</link>
      <description>&lt;P&gt;I kind of follow what you mean, do have have more of an example?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is what I am trying now, It's getting to the point of trying to log on to the remote telnet device but it's not logging on.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;#192.168.0.120 = Cisco Router running SSH
#100.60.1.1 = Far end router running telnet


from __future__ import unicode_literals, print_function
import time
from netmiko import ConnectHandler, redispatch

import logging
logging.basicConfig(filename='test.log', level=logging.DEBUG)
logger = logging.getLogger("netmiko")


cisco = {
    'device_type': 'cisco_ios',
    'host': '192.168.0.120',
    'username': 'admin',
    'password': 'admin',
     }

net_connect = ConnectHandler(**cisco)

output = net_connect.write_channel("telnet 100.60.1.1"  + '\r\n')
time.sleep(.5)

# Manually handle the Username and Password
max_loops = 10
i = 1
while i &amp;lt;= max_loops:
    output = net_connect.read_channel()

    if 'Username:' in output:
        net_connect.write_channel(net_connect.username  + '\r\n')
        time.sleep(1)
        output = net_connect.read_channel()

    # Search for password pattern / send password
    if 'Password' in output:
        net_connect.write_channel(net_connect.password + '\r\n')
        time.sleep(.5)
        output = net_connect.read_channel()
        # Did we successfully login
        if '&amp;gt;' in output or '#' in output:
            break


&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 11 Mar 2020 09:43:38 GMT</pubDate>
      <guid>https://community.cisco.com/t5/controllers/use-cisco-router-as-a-jump-host-with-python-for-ssh-and-telnet/m-p/4044061#M1971</guid>
      <dc:creator>velo84</dc:creator>
      <dc:date>2020-03-11T09:43:38Z</dc:date>
    </item>
    <item>
      <title>Re: Use Cisco Router as a jump host with Python (for SSH and Telnet)</title>
      <link>https://community.cisco.com/t5/controllers/use-cisco-router-as-a-jump-host-with-python-for-ssh-and-telnet/m-p/4051886#M1972</link>
      <description>&lt;P&gt;&lt;U&gt;&lt;STRONG&gt;Please have a look at pyATS&amp;nbsp;&lt;/STRONG&gt;&lt;/U&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://github.com/CiscoTestAutomation/CL-DEVWKS-2808/blob/master/workshop.md" target="_blank"&gt;https://github.com/CiscoTestAutomation/CL-DEVWKS-2808/blob/master/workshop.md&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Automation revolves around being able to programmatically establish connection to your testbed devices. There are tools out there today that help you with this, for example:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;A href="http://www.paramiko.org/" rel="nofollow" target="_blank"&gt;Paramiko&lt;/A&gt;: Python implementation of SSH client&lt;/LI&gt;&lt;LI&gt;&lt;A href="https://pexpect.readthedocs.io/en/stable/" rel="nofollow" target="_blank"&gt;Pexpect&lt;/A&gt;: Python module for spawning child applications (e.g., telnet/ssh) and interacting with them&lt;/LI&gt;&lt;LI&gt;&lt;A href="https://github.com/ktbyers/netmiko" target="_blank"&gt;Netmiko&lt;/A&gt;: multi-vendor library that simplifies Paramiko SSH connections to network devices&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;These libraries are good at establishing low-level connectivity to your devices, and allow basic device interactions. However, what they do not provide is high-level services: stateful handling of various router/switch prompt states, and advanced mechanisms such as dialogs prompts, etc.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here are some neat functionalities w.r.t. Unicon:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Automatically learn the hostname (within reason)&lt;/LI&gt;&lt;LI&gt;Log connection interactions to a whole separate file&lt;/LI&gt;&lt;LI&gt;&lt;STRONG&gt;Connection through proxies (jump hosts)&lt;/STRONG&gt;&lt;/LI&gt;&lt;LI&gt;RobotFramework support/keys&lt;/LI&gt;&lt;/UL&gt;</description>
      <pubDate>Wed, 25 Mar 2020 09:19:07 GMT</pubDate>
      <guid>https://community.cisco.com/t5/controllers/use-cisco-router-as-a-jump-host-with-python-for-ssh-and-telnet/m-p/4051886#M1972</guid>
      <dc:creator>omz</dc:creator>
      <dc:date>2020-03-25T09:19:07Z</dc:date>
    </item>
    <item>
      <title>Re: Use Cisco Router as a jump host with Python (for SSH and Telnet)</title>
      <link>https://community.cisco.com/t5/controllers/use-cisco-router-as-a-jump-host-with-python-for-ssh-and-telnet/m-p/4051991#M1973</link>
      <description>&lt;P&gt;Thanks, I'm using netmiko already. It complicates things because I am using a Cisco router as a jump host for telnet so you have to write in every behaviour.. I'm making some progress. Thanks&lt;/P&gt;</description>
      <pubDate>Wed, 25 Mar 2020 12:00:46 GMT</pubDate>
      <guid>https://community.cisco.com/t5/controllers/use-cisco-router-as-a-jump-host-with-python-for-ssh-and-telnet/m-p/4051991#M1973</guid>
      <dc:creator>velo84</dc:creator>
      <dc:date>2020-03-25T12:00:46Z</dc:date>
    </item>
  </channel>
</rss>

