Automate FTP server logins from the Terminal

Dec 10, '01 11:40:51AM

Contributed by: Anonymous

You can make file that holds a list of machines and their associated usernames and passwords quite easily. This file is also recognized by wget (a powerful ftp and http client). You need to be in your home directory and type

pico .netrc
This will open a text editor into which you type:
machine machine_name_or_IP# user your_username password  your_password
Then type control-X to save the file and exit from pico.

At the terminal prompt type:
chmod 700 .netrc.
This makes the file readable only by you.

Now when you ftp to that machine you will automatically log in. You can add additional machines one line at a time. If you want, you can make the last line look like this:
default user anonymous password name@machine.net
This will enable anonymous login. Even better is that wget recognizes this file and automatically logs into the machines specified. I got this from the ftp man page ('man ft' in the Terminal), very near the bottom. Enjoy!

Comments (2)


Mac OS X Hints
http://hints.macworld.com/article.php?story=20011210114051576