Using the netrc file for curl

Using a netrc file in curl is useful to avoid typing your password for each new request.

The syntax of your netrc file is as follows :

machine fqdn_of_your_server
login your_login
password your_password

If you log in using any LDAP-based authentication, make sure to add the DOMAIN.

machine fqdn_of_your_server
login your_login@DOMAIN
password your_password

Make sure to change the permissions on your netrc file :

chmod 600 netrc

By default, curl looks for a netrc file in your home directory.
If needed, you can manually mention the location of your netrc file :

curl --netrc-file mynetrc


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.