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 every time.
This guide walks you through how to create and secure your .netrc file to store your EDL credentials.
Key Things to Know
The general
.netrcformat is:machine urs.earthdata.nasa.gov login your_username password your_passwordExample:
machine urs.earthdata.nasa.gov login NSIDCDAACUser password IloveNSIDCDAACImportant: Never share your
.netrcfile. Keep this file private and never share it.- Set appropriate file permissions to prevent unauthorized access.
The
.netrcfile must be in your Home directory. Use these commands to find your HOME directory location:For UNIX systems:
echo $HOMEFor Windows systems:
echo %HOMEDRIVE%%HOMEPATH%
Create your
.netrcfile (or_netrcon 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 touch command to create an empty file:
touch ~/.netrc2. Set file permissions to restrict access:
chmod 0600 ~/.netrcThis 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. Then, use the following echo command to store your EDL credentials. Replace the placeholders your_username and your_password with your actual login and password.
echo 'machine urs.earthdata.nasa.gov login your_username password your_password' >> ~/.netrc4. You can check the contents of your .netrc file
cat ~/.netrcWindows
1. Open a PowerShell session and create a $HOME environment variable using the following command:
[Environment]::SetEnvironmentVariable("HOME", $env:USERPROFILE, "User")2. Create a new empty _netrc file using the New-Item command, and then set file permissions using the icacls command:
New-Item -Path "$HOME/_netrc" -ItemType File
icacls "$HOME\_netrc" /inheritance:r /grant:r "${env:USERNAME}:F"3. Then, use the Add-Content command to append your credentials to the file. Replace the placeholders your_username and your_password with your actual login and password.
Add-Content -Path "$HOME\_netrc" -Value 'machine urs.earthdata.nasa.gov login your_username password your_password' -Encoding ASCII4. If your username or password contain special characters, such as $ or ‘, you may need to add your EDL credentials manually. You can open and edit the _netrc file in notepad by running the command:
notepad "$HOME\_netrc"