The Getpass module provides the functions:
Getpass.getpass (prompt= ' Password: ', Stream=none)
Prompt the user for a password without echoing. The user is prompted using the string prompt, which defaults to ' Password: '. On Unix, the prompt are written to the File-like object stream using the Replace error handler if needed. Stream defaults to the controlling terminal (/dev/tty) or if that's unavailable to Sys.stderr (this argument is ignored O n Windows).
Exception Getpass. Getpasswarning?
A userwarning Subclass issued when password input is echoed.
Getpass.getuser ()
Return the "login name" of the user.
This function checks the environment variables LOGNAME, USER, LNAME and USERNAME, in order, and returns the value of the F Irst one which is set to a non-empty string. If None is set, the login name from the password database was returned on systems which support the PWD module, otherwise, An exception is raised.
In general, this function should is preferred over os.getlogin ().
Some of the packages in Python3 Getpass