I am using the Netmiko library to communicate with a network device. When we run the script, the user will be prompted to enter username/password.

I want to hide the password part while the user is entering it (obviously).

I tried using getpass but I think it's not working. It doesn't authenticate at all.

Please help me find the correct step.

I imported the connection handler from Netmiko.

I imported getpass.

I used the result of getpass() in the connection handler but doesn't work.

import getpass

from netmiko import ConnectHandler

user = input('Username:')

p = getpass.getpass()

device = ConnectHandler(device_type='juniper_junos', ip='x.x.x.x',
                        username=user, password=p)

I expect

Username: ironman

Password:

***output***

0 Answers