FTP Configuration with Net::Netrc
Unix-based FTP clients use a file called .netrc, which you can configure to automate FTP access to sites you frequently visit. With a properly defined .netrc file, you can simply execute the FTP command to a favorite FTP host and be automatically logged in to the FTP server. Your .netrc file contains one line for each connection you want to make. The following tokens can be specified for each entry:
machinenameSpecifies a remote machine to which you want to autologin:
machine remotehost.com
Instead of
machinename, you can specify the single worddefaultto match any machine name. This is usually used for anonymous logins to machines not listed in .netrc.loginnameIf present, identifies the user who logs in to the remote machine, in which
nameis the login name.passwordpasswdIf present, gives the password for the user. The autologin process uses the specified password if the remote server requires one.
accountacctpwIf present, gives an additional password for the user. The autologin process uses this password if the remote server requires one.
macdefnameIf present, defines a macro with the specified name. Net::Netrc simply parses this field, to maintain compatibility with FTP.
Here’s an example of a typical .netrc entry:
machine remotehost.com login username password userpasswd
Entering your username and password for remote sites in unencrypted form has serious security implications. Many sites consider .netrc files a violation of security policy ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access