# Using .netrc with curl for Automatic Authorisation

The ~/.netrc file can store credentials. This can include things like OAuth tokens and plain text passwords.

Warning: Be very careful if you decide to store passwords in this file. The file is not encrypted, so you’ll be storing your password in plain text on the disk. This is generally a bad idea!

First, create the file and make it readable by only yourself:

touch ~/.netrc
chmod go= ~/.netrc


Then edit the file to contain lines that look like the following (one line per machine):

machine the.address.tld login the-username password the-password


curl can then read this file by providing the --netrc option:

curl --netrc http://the.address.tld/classified