banner motd change failing on Juniper device
See original GitHub issueGood afternoon, I am new to programming and am very excited to learn about Netmiko. I am trying to change the Banner Motd on more than 100 Juniper devices (RT and SWITCH) but it is giving me the following error.
File “02_Banner.py”, line 38, in <module>
output = net_connect.send_config_set(banner, exit_config_mode=False)
File “/usr/local/lib/python3.6/site-packages/netmiko/base_connection.py”, line 1782, in send_config_set
new_output = self.read_until_pattern(pattern=re.escape(cmd.strip()))
File “/usr/local/lib/python3.6/site-packages/netmiko/base_connection.py”, line 641, in read_until_pattern
return self._read_channel_expect(*args, **kwargs)
File “/usr/local/lib/python3.6/site-packages/netmiko/base_connection.py”, line 575, in _read_channel_expect
“Timed-out reading channel, data not available.”
netmiko.ssh_exception.NetmikoTimeoutException: Timed-out reading channel, data not available.
The script is quite simple which I share. (change banner text)
from netmiko import ConnectHandler
from netmiko.ssh_exception import NetMikoTimeoutException
from netmiko.ssh_exception import NetMikoAuthenticationException
from paramiko.ssh_exception import SSHException
IP_LIST_JUNIPER = open('eqjuniper')
for IP in IP_LIST_JUNIPER:
dis = {
'device_type': 'juniper',
'ip': IP,
'username': 'juniper',
'password': 'juniper',
}
print ('\n### CONNECTING TO THE DEVICE' +'_'+ IP.strip() + '###\n')
try:
net_connect = ConnectHandler(**dis)
except NetMikoTimeoutException:
print ('\n###DISPOSITIVO INALCANZABLE .###\n')
continue
except NetMikoAuthenticationException:
print ('\n### AUTHENTICATION FAILURE.###\n')
continue
except SSHException:
print ('\n### Make sure SSH is enabled on the device.###\n')
continue
banner = ["set system login message '################################################################################\n#This system should be used business or for purposes #\n# It is mandatory to comply with all the #\n#requirements listed in the applicable security policy and only process #\n#or store the data classes approved for this asset type. Use is subject #\n. #################################################################################'"]
output = net_connect.send_config_set(banner, exit_config_mode=False)
print(output)
I will be very grateful for your help
Issue Analytics
- State:
- Created 3 years ago
- Comments:12 (5 by maintainers)
Top GitHub Comments
Hi @ibolt1,
Try using host as key instrad of ip for the device definition dictionary:
Kind regards, Veprim
Hi @ktbyers I have the latest version of netmiko installed v3.2.0
CODIGO: from netmiko import ConnectHandler from netmiko.ssh_exception import NetMikoTimeoutException from netmiko.ssh_exception import NetMikoAuthenticationException from paramiko.ssh_exception import SSHException
IP_LIST_JUNIPER = open(‘juniper’) for IP in IP_LIST_JUNIPER: dis = { ‘device_type’: ‘juniper’, ‘ip’: IP, ‘username’: ‘test’, ‘password’: ‘test1’, }
Juniper team result: test@test1# show | compare [edit system login]
{master:0}[edit]
when it is presented with the argument \ n the message is cut and it does not continue with what else thank you