Netrc file contains user credentials and is used to auto-login. It is usually located in users home directory
.netrc but location can be overridden with
NETRC environment variable. Netrc also supports macros
macdef to automate tasks. Netrc can be used with ftp, curl, git etc.
- Create file named
.netrcin home directory.
- Lets consider your git server is hosted on domain
~ $ cat .netrc machine git.company.com login first.last password secret-password
.netrcis used to store credentials, lets secure the file.
~ $ chmod 0600 ~/.netrc
That's it, next time when you use git for domain
git.company.com, git should pick up the credentials on behalf of you ;)
- Netrc stores credentials in plan text. This is how netrc is meant to be ;)
- Its a good idea to use netrc when you have token based authentication.
- Automation for service accounts with token based authentication.