question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

banner motd change failing on Juniper device

See original GitHub issue

Good 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:open
  • Created 3 years ago
  • Comments:12 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
veprimkcommented, Aug 20, 2020

Hi @ibolt1,

Try using host as key instrad of ip for the device definition dictionary:

dis = {
             'device_type': 'juniper',
             'host': IP,
             'username': 'juniper',
             'password': 'password',
         }

Kind regards, Veprim

0reactions
ibolt1commented, Aug 27, 2020

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’, }

print ('\n### CONNECTING TO THE DEVICE' +'_'+ IP.strip() + '###\n')
try:
    net_connect = ConnectHandler(**dis)
except NetMikoTimeoutException:
    print ('\n### UNREACHABLE DEVICE.###\n')
    continue

except NetMikoAuthenticationException:
    print ('\n### AUTHENTICATION FAILURE.###\n')
    continue
except SSHException:
    print ('\n### Make sure SSH is enabled on the device.###\n')
    continue

print ('\n##### INITIATING BANNER CONFIGURATION #####\n')

banner = ['set system login message "######################################################################################################\n#This system should be used for conducting business or for purposes authorized by management.#\n#It is mandatory to comply with all the requirements listed in the applicable security policy and     #\n#only process or store the data classes approved for this asset type. Use is subject                  #\n#to audit at any time by management.				                              #\n#######################################################################################################"']

output = net_connect.send_config_set(banner, cmd_verify=False, delay_factor=2)   
print(output)

Juniper team result: test@test1# show | compare [edit system login]

  • message " ";
  • message "###################################################################################################### ";

{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

Read more comments on GitHub >

github_iconTop Results From Across the Web

Login Settings | Junos OS - Juniper Networks
Junos OS enables you to define various settings for users when they log in to a device. You (the system administrator) can configure:...
Read more >
Creating a MOTD Banner | Switching
I am trying to migrate a banner from Cisco to JunOS, but I am not able to convert it correctly.Please check the attachment...
Read more >
Configuring CLI Messages - Technical Documentation - Support
Failure to do so may produce undesired results. To configure MOTD, login, or exec banner to be displayed by the CLI: Issue the...
Read more >
Open Issues | Junos OS Evolved - Juniper Networks
Learn about open issues in Junos OS Evolved Release 21.3R1 for QFX Series ... change with ECMP dynamic mode, so ECMP Create API...
Read more >
Open Issues | Junos OS Evolved - Juniper Networks
Learn about open issues in Junos OS Release 21.3R1 for PTX Series Routers.. ... use the Juniper Networks online Junos Problem Report Search...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found