Creating a .netrc File for Earthdata Login
A .netrc
file is a plain text configuration file used to securely store login credentials for automated authentication. When accessing NASA Earthdata resources, a .netrc
file allows seamless authentication without being prompted for your Earthdata Login (EDL) username and password everytime.
This guide walks you through how to create and secure your .netrc
file to store your EDL credentials.
Key Things to Know
The general
.netrc
format is:machine urs.earthdata.nasa.gov login your_username password your_password
Example:
machine urs.earthdata.nasa.gov login NSIDCDAACUser password IloveNSIDCDAAC
Important: Never share your
.netrc
file. Keep this file private and never share it.- Set appropriate file permissions to prevent unauthorized access.
The
.netrc
file must be in your Home directory. Use these commands to find your HOME directory location:For UNIX systems:
echo $HOME
For Windows systems:
echo %HOMEDRIVE%%HOMEPATH%
Create your
.netrc
file (or_netrc
on Windows) in the directory indicated by the command output.
Instructions by Operating System
Unix/Linux/macOS
1. Open a command line terminal and use the following echo command to store your EDL credentials. Replace the placeholders with your actual login and password.
echo 'machine urs.earthdata.nasa.gov login your_username password your_password' >> ~/.netrc
2. Set file permissions to restrict access:
chmod 0600 ~/.netrc
This step is crucial. It makes the file readable and writable only by you. If the permissions are too permissive, many tools will refuse to use the file.
3. You can check the contents of your .netrc
file
cat ~/.netrc
Windows
1. Open Notepad or any plain-text editor.
2. Enter the .netrc
format shown above, replace the placeholders with your actual login and password.
3. Save the file as _netrc
(with an underscore instead of a period) in your home directory.
4. Set file permissions:
- Right-click
_netrc
file and choose Properties - Go to the Security tab → Click Edit
- Remove access for all other users except your own account
- Click Apply to save the changes.