Replies: 3 comments
-
@slieberth What is the advantage of this over just using Regards, Kirk |
Beta Was this translation helpful? Give feedback.
-
Hello Kirk, Thank you very much for your quick response. Please take my idea with humor from someone who wasn't quite familiar with Netmiko and didn't know about the device type 'terminal_server' and the 'redispatch' method. I tested it; everything works wonderfully. Please forget my idea, and thanks again for Netmiko! best regards import time
from netmiko import ConnectHandler, redispatch
# Establish connection to the terminal server
terminal_server = {
'device_type': 'terminal_server',
'host': '192.168.2.78',
'username': 'admin',
'password': 'avocent',
'port': 7011,
'session_log': 'session_log.txt', # Optional: logs the session
}
# Initiate connection to the terminal server
net_connect = ConnectHandler(**terminal_server)
print("Connected to the terminal server.")
redispatch(net_connect, device_type='cisco_ios')
# Example: Execute a command on R1
output = net_connect.send_command('show version')
print(output)
# Close terminal line on the terminal server
print("Sending <CTRL>-Z and exit to close console session...")
net_connect.write_channel("\x1a") # <CTRL>-Z
time.sleep(1)
net_connect.write_channel("exit\n")
time.sleep(1)
# Close terminal line on the terminal server
net_connect.disconnect()
print("Session disconnected.") |
Beta Was this translation helpful? Give feedback.
-
No worries at all @slieberth |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi Kirk, hello Netmiko Community
First of all – thank you for your amazing work on Netmiko. It's a critical tool in our automation workflows.
I've recently developed a Netmiko extension that allows you to connect to network devices via terminal servers. This is particularly useful for console-based access in lab setups, remote OOB management, or provisioning environments. In theory this approsch could also be used in combination with jump hosts.
The module wraps a live paramiko shell in a custom BaseConnection subclass and integrates prompt detection, paging control, and graceful session teardown (-Z + exit).
The basic idea is that paramiko prepares the channel through the console server and hands it of to netmiko for further communication.
You can find the full implementation, usage example, and README here: 👉 https://github.com/slieberth/Netmiko-Based-Console-Connector
I'd love to get your feedback on a couple of points:
Thanks again for your great work and the whole Netmiko community!
Best regards,
Stefan Lieberth
Beta Was this translation helpful? Give feedback.
All reactions