plain Password is logged via my python script
Question: I have a sample python script: sample.py. The script takes the argument as the
user name and password to connect to some remote server. When I run the script
sample.py --username --password , the password is being logged in linux
messages files. I understand this is a linux behavior, but wondering if we can
do anything within my script to avoid this logging. One way I can think is to
provide password in an interactive way. Any other suggestions?


Answer: Python has the
[getpass](https://docs.python.org/2/library/getpass.html#module-getpass)
module to handle both user and password information, though these are provided
in an interactive way, as you suggested, but with an additional layer of
security. It's also quite simple to use, having the `getpass` and `getuser`
methods available.

Example:

    
    
    import getpass
    
    password = getpass.getpass() # Prompts "Password:" automatically
    

