.netrc File Builder
Build a ~/.netrc file (curl, ftp, git credential) with multiple 'machine HOST' entries (login, password, optional account) and a single 'default' fallback. Rejects passwords with '#' or whitespace (which break parsers) and reminds you to chmod 600.
Add one entry per line, in the form host login password [account] or default login password.
About ~/.netrc
The ~/.netrc file is read by curl, ftp and git (through a credential helper) to authenticate without prompting. The curl parser accepts neither spaces nor # inside a token, so this tool rejects both. Once the file is written, run chmod 600 ~/.netrc — otherwise those tools refuse to use it.
What the .netrc file does
The .netrc file is a 1970s convention for storing login credentials so command-line tools can authenticate non-interactively. It lives at ~/.netrc (or %USERPROFILE%\_netrc on Windows), must be readable only by its owner (chmod 600), and is consumed by curl (--netrc, --netrc-file), wget, the legacy ftp client, git (via credential helpers), Python's urllib and Java's URLConnection. It is plain text — that is both the appeal and the security risk.
File format
Entries are blank-line separated. Each entry has a machine line (or the special default fallback), a login, a password and optionally an account token. Tokens cannot contain spaces or #:
machine ftp.example.com
login alice
password s3cret
account billing
machine github.com
login alice
password ghp_xxxxxxxxxxxxxxxxxxxx
default
login anonymous
password [email protected]
The default stanza is the fallback for any host not explicitly listed. The deprecated macdef directive used to define FTP macros and is best avoided.
Security trade-offs and modern alternatives
The file is plain text. Anyone who reads it reads your passwords — including a misconfigured backup, a shared dotfiles repository, a stolen laptop. Stronger alternatives are OS-level keystores: macOS Keychain, GNOME Keyring / KWallet on Linux, Windows Credential Manager. The gh CLI uses the keyring instead of .netrc. For team and server use, HashiCorp Vault, AWS Secrets Manager, Doppler and 1Password CLI are the modern path. In CI, GitHub Actions and GitLab CI inject secrets as environment variables — Docker has dedicated secrets mounts. Use .netrc for personal, short-lived tokens; rotate them often.
Best practices
chmod 600 ~/.netrcimmediately after creation — curl refuses to read it otherwise.- Never commit the file to git or any dotfiles repository.
- Use short-lived personal access tokens, not long-term passwords.
- Rotate tokens periodically — quarterly for low-risk, monthly for production credentials.
- Encrypt the home volume (FileVault, LUKS) so a stolen disk does not reveal the file.
- Use a separate
--netrc-file /path/to/custom.netrcper project when contexts diverge.
FAQ
Should I check .netrc into git? No. Ever. Add .netrc to .gitignore globally (git config --global core.excludesfile ~/.gitignore_global) so you cannot leak it by mistake.
Is .netrc still used in 2026? Yes, in legacy curl, wget and FTP workflows, and as a quick way to script against private APIs from the shell. New software prefers OS keychains and OIDC tokens.
Why must I run chmod 600? curl, ftp and most libraries refuse to read a file with group or world permissions, precisely to prevent leaking credentials by accident.
Is any data sent to a server? No. The file is composed in your browser and written to the output block — nothing is uploaded.
Related Tools
tar Command Builder
Build tar commands (create, extract, list) with gz/bz2/xz/zst compression and exclusion patterns.
SSML Builder (Speech)
Build SSML (Speech Synthesis Markup) documents compatible with Alexa, Google and Polly with break, prosody, emphasis, phoneme and voice tags.
OKR Builder (1 Objective + 3 Key Results)
Takes one qualitative objective and three measurable key results and lays them out as a formatted OKR block ready to paste into a plan or review doc.
curl Form Builder
Build curl commands with multipart -F or urlencoded -d, including @file fields with content type.
WebFinger JRD Builder (RFC 7033)
Build a JRD (JSON Resource Descriptor) for WebFinger (.well-known/webfinger) responses with acct: subject, aliases, properties and links (rel, type, href) — as used by Mastodon/ActivityPub.
.env File Generator by Stack
Creates complete .env and .env.example files for common stacks (Next.js, Django, Rails, Laravel, Vite) with placeholders and documented comments.