unix

How do I set up a passwordless FTP connection?

You can use a .netrc file to enable you to have a passwordless FTP connection.

# vi .netrc
machine myftpserver.com
login myusername
password mypassword

chmod 600 .netrc

Now just ftp to that server like this:

ftp myftpserver.com

It will connect using the login information in your .netrc file.

You can add more entries like the example above in your .netrc so you can connect to various FTP servers without being prompted for a password.

machine myftpserver.com
login myusername
password mypassword

machine myotherftpserver.com
login myotherusername
password myotherpassword

And Voila! You don’t need to type your password to connect anymore.

You can also set up macros for tasks you perform often and add them to your .netrc.

macdef uploadtest
cd /pub/tests
bin
put filename.tar.gz
quit

macdef dailyupload
cd /pub/tests
bin
put daily-$1.tar.gz
quit

ftp myftpserver.com
ftp>$ uploadtest
cd temp
250 CWD command successful.
put filename.tar.gz
local: filename.tar.gz remote: filename.tar.gz
150 Opening BINARY mode data connection for ‘filename.tar.gz’
100% |**************************************************| 1103 00:00 ETA
226 Transfer complete.
1103 bytes sent in 0.01 seconds (215.00 KB/s)
quit
221 Goodbye.

What the example above did was call the macro we defined as uploadtest and ran it.

Click to comment

Leave a Reply

Your email address will not be published. Required fields are marked *

To Top