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.

Updating local accounts password

See original GitHub issue

Hi,

I am trying to update the local account on all of my Juniper and some Cisco devices, but I could not get this to work. I did not get an error and I got the print at the end of the for loop. When I logged in to any of the device 10.1.1.1, the account I was using for testing, the password did not change.

from netmiko import ConnectHandler
import getpass

junos_list = ['10.1.1.1']

username = input("Username : ")
password = getpass.getpass("Password : ")


print("Enter the account you would like to update")
local_user = input("Local account username : ")
new_password = input ("Enter the new password : ")


#Juniper device root account
if (local_username == "root") and (username == "admin"):   
    for i in junos_list:
        userssh = ConnectHandler(device_type='juniper_junos', ip=i, port=22, username=username, password=password)
        root_login_cred = ('set system root-authentication plain-text-password')
        root_login_passwd = (new_password)
        root_login_confirm_passwd = (new_password)
        userssh.send_config_set(root_login_cred)
        userssh.send_config_set(root_login_passwd)
        userssh.send_config_set(root_login_confirm_passwd)
        userssh.disconnect()
        print("\n\tThe root password has been updated for", i)
else:
    for la in junos_list:
        userssh = ConnectHandler(device_type='juniper_junos', ip=la, port=22, username=username, password=password)
        la_login_cred = ('set system login user ' + local_user +  ' authentication plain-text-password')
        la_login_passwd = (new_password)
        la_login_confirm_passwd = (new_password)
        config_commands = ([la_login_cred, la_login_passwd, la_login_passwd])
        userssh.send_config_set(config_commands)
        userssh.send_config_set(la_login_passwd)
        userssh.send_config_set(la_login_confirm_passwd)
        userssh.commit()
        userssh.disconnect()
        print("\n\tThe password has been updated for node", la)
        

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
dasiimwecommented, Jan 18, 2021

@ktbyers, Thanks for the quick response. Will do.

Meanwhile, i found a work around for this. Junos has a hidden command ‘plain-text-password-value’ that allows you to enter the password on the same line and avoid the password prompt.

source: https://www.reddit.com/r/networking/comments/9ptwte/python_and_junos

0reactions
ktbyerscommented, Jan 15, 2021

@dasiimwe You should open a new issue (or better would be a Netmiko Github discussion question).

Regards, Kirk

Read more comments on GitHub >

github_iconTop Results From Across the Web

Change local account password in Windows 10
Press Windows key + R. · Type netplwiz and hit Enter. · Under User account windows, select the User Profile for which you...
Read more >
How to change your account password on Windows 10
In this guide, you'll learn the steps to change your account password on Windows 10, whether you're using a Microsoft or local account....
Read more >
How do I change a local user account password?
Type Control Panel in the Cortana/Search box. Open Control Panel and click on User accounts. My Computers.
Read more >
How to Change Another User's Password in Windows - Lifewire
Windows 11, 10 & 8: Go to Control Panel > User Accounts > User Accounts > Manage another account > [user]. Select Change...
Read more >
How to reset a Microsoft Account password for Windows 10 or ...
Update Windows 10 local account security questions · At the desktop, press the Windows key and type "sign." Select Sign-in options from the...
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