From mn/geo/geoit
Jump to: navigation, search

The netrc module is a nice way to store credentials securely:

First create a ~/.netrc file in your home directory. Include the following:

 username your_username
 password your_password

Make sure that the file is properly protected with the appropriate permissions.

Then in your python script, to access the username and password simply:

import netrc

HOST = ''
secrets = netrc.netrc()
username, account, password = secrets.authenticators( HOST )

and you're set! You can easily call the netrc settings from any python script.

Here's a helpful example of using the [smtp]( tools in python.