Netmiko with intermediate SSH jumpserver using redispatch

Hello lions,

I need to use netmiko with redispatch option for Nornir, as it is working for me with netmiko using below template, but i need to apply it with Nornir and make it the default ssh for all use cases. Thanks

windows(script server) – Linux(jump server) – Router

jumpserver = {‘device_type’: ‘terminal_server’,‘ip’: IP,‘username’: User,‘password’: Pass,‘default_enter’: ‘\r\n’,‘global_delay_factor’: 5}

net_connect = ConnectHandler(**jumpserver)

net_connect.find_prompt()
server = net_connect.read_channel()
net_connect.write_channel(‘ssh -l’ + User + ’ ’ + Device)
net_connect.write_channel(’\n’)

redispatch(net_connect, device_type=‘cisco_ios’, session_prep=False)

net_connect.send_command(’\n’)
net_connect.send_command(‘terminal length 0’)
get_cdp_neighbor_details = net_connect.send_command(“show cdp neighbor detail”, delay_factor=5)
net_connect.send_command_expect(‘exit’, expect_string=str(ServerPrompt))

redispatch(net_connect, device_type=‘terminal_server’)

ServerPrompt = net_connect.find_prompt(delay_factor=1)
net_connect.disconnect()

can anyone help me please

What is the issue? You just want the above in a Nornir context?

Assuming yes, then just make a Grouped Task and manually create the Netmiko connection and execute your relevant code.

Here is an example that gets you part of the way there:

1 Like

many thanks for your solution, it worked for me and i modified internal netmiko connection script with my jump, and it worked also.

But, i still have an issue to run the direct netmiko plugin as below:

results = nr.run(task=netmiko_send_command, command_string="show ip int brief ")

I am not sure I understand the question? You can’t run the above command in a redispatch/jump-server context? Or you just can’t run the command in a normal manner?