• 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 Move Swap From Disk Partition to LVM Volume in Linux
  2. Understanding The /etc/sysconfig Directory
  3. How to cancel or pause live migrations using virsh
  4. How to disable auto completion (tab completion) in bash shell
  5. Beginners Guide to Swap Space Management in Linux
  6. Starting iptables Fails with Error “Another app is currently holding the xtables lock”
  7. How to Log dropped packets using firewalld in CentOS/RHEL 7
  8. mailstat Command Examples in Linux
  9. Beginners Guide to DHCP – Install and configure DHCP server and client
  10. Tutorial on Linux Clustering (High Availability)

You May Also Like

Primary Sidebar

Recent Posts

  • vgextend Command Examples in Linux
  • setpci command – configure PCI device
  • db_load command – generate db database
  • bsdtar command – Read and write tape archive files

© 2022 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright