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

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • Solaris
    • Oracle Linux
    • VCS
  • Interview Questions
  • Database
    • oracle
    • oracle 12c
    • ASM
    • mysql
    • 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. How to change the default permissions on /var/log/audit/audit.log file in CentOS/RHEL
  2. bat Command Examples in Linux
  3. kdocker Command Examples in Linux
  4. 7 Useful Find Command Examples to Locate files to remove when a filesystem is full
  5. How Files/Directories in /tmp gets Removed Automatically in CentOS/RHEL 5,6
  6. How to effectively use Man Pages under Linux
  7. gdebi Command Examples in Linux
  8. pw-cat Command Examples in Linux
  9. How to Back Up and Restore XFS File Systems (xfsdump / xfsrestore)
  10. How To Auto Mount a FileSystem Using Systemd

You May Also Like

Primary Sidebar

Recent Posts

  • qm Command Examples in Linux
  • qm wait Command Examples in Linux
  • qm start Command Examples in Linux
  • qm snapshot Command Examples in Linux

© 2023 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright