Last active
August 16, 2024 23:32
-
-
Save nitrocode/ce888d3eb529cf78f4e0 to your computer and use it in GitHub Desktop.
Run an ssh command on Enterasys or Extreme switches using netmiko
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# This will run an ssh command successfully on an enterasys SSA and so SSH must be enabled on the device(s). | |
# paramiko can be used but netmiko simplifies the code for these switches if you set the device_type to "a10" | |
from netmiko import ConnectHandler | |
#enterasyshandle = {'device_type':'a10', 'ip' : '10.54.116.175', 'username':'admin', 'password':''} | |
enterasyshandle = {'device_type':'enterasys', 'ip' : '10.54.116.175', 'username':'admin', 'password':''} | |
net_connect = ConnectHandler(**enterasyshandle) | |
output = net_connect.send_command('show config policy') | |
print(output) | |
#extremehandle = {'device_type':'a10', 'ip' : '10.54.149.80', 'username':'admin', 'password':''} | |
extremehandle = {'device_type':'extreme', 'ip' : '10.54.116.175', 'username':'admin', 'password':''} | |
net_connect = ConnectHandler(**extremehandle) | |
output = net_connect.send_command('show config vlan') | |
print(output) |
@fescalero this script is very basic as it passes the username
argument directly into netmiko
. Have you considered opening up an issue with netmiko
?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I have a problem with this code. First if we have a username like "[email protected]". I have tried to solve this using "user\@mydomain.com" or "'[email protected]'" .
Also I have a error like "Error reading SSH protocol banner" . I have tried to solve with 'banner_timeout': 200 and also with 'ssh_strict': False , but it doesn't work.
The device is a C5 model.