• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer navigation

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • VCS
  • Interview Questions
  • Database
    • MariaDB
  • DevOps
    • Docker
    • Shell Scripting
  • Big Data
    • Hadoop
    • Cloudera
    • Hortonworks HDP

Set FTP Autologin with .netrc file in Linux

by admin

There are some scenarios where we do not want to specify ftp user name and password on the ftp command line. So to automatically supply ftp username and password to the ftp client, create a file .netrc in the user’s home directory which contains the information regarding the ftp server name, ftp user & password.

We can also use .netrc file in a shell script where we will use ftp client to transfer files to remote ftp server.

Below are the steps to enable FTP autologin with the .netrc file.

Create a .netrc file in user’s home directory

# vi ~/.netrc
machine [FTP-Server-Name] login [User-Name] password [XXXXX]

For example:

machine  ftp.nstpmail.com  login ftp-user password xyz@abc123

Save & Exit the file.

Note: We can add multiple machines ,Just one line per machine in the .netrc file.

Set permissions

Set permissions of the .netrc file so that only owner can readt the file:

# chmod 0600 ~/.netrc

Try Connecting FTP server

Npw you can try connecting your FTP server as shoen below:

# ftp [FTP-Server-Name]

Now above command will connect to your ftp server automatically, whereas ftp user name and password is picked up from .netrc file

Filed Under: Linux

Some more articles you might also be interested in …

  1. locale Command Examples in Linux
  2. CentOS / RHEL 5 : How to Configure kdump
  3. fakedata: Generate fake data using a large variety of generators
  4. fdroidcl – F-Droid CLI client
  5. Linux OS Service ‘cpuspeed’
  6. lwp-request Command Examples
  7. Installation Steps of jEdit on Ubuntu Linux
  8. csslint: A linter for CSS code
  9. acme.sh –dns: Use a DNS-01 challenge to issue a TLS certificate (Command Examples)
  10. clear: Clears the screen of the terminal (Command Examples)

You May Also Like

Primary Sidebar

Recent Posts

  • Vanilla OS 2 Released: A New Era for Linux Enthusiasts
  • mk Command Examples
  • mixxx Command Examples
  • mix Command Examples

© 2025 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright