Using ftp in Terminal without entering password
If you use the ftp-client in Terminal frequently, then it is probably to log in to the same server, entering the same username and the same password.
There has got to be a more clever way to log-in every time. Here is how – however, have in mind, it involves having the username and password in a plain text file in your home directory, although it is hidden. We will modify the rights so only the logged-in user can read and modify the file. If you can live with that, then here goes.
The ftp-client looks for a file called .netrc with information about the server to be logged in to. Say, you normally type ftp ftp.yourdomain.com, then you just enter the following in a text file which you save to the name .netrc in ~.
machine ftp.yourdomain.com
login your_user_name
password your_password
machine ftp.anotherdomain.com
login another_username
password another_password
Notice, there must be a blank line between.
When this file is saved, do chmod 600 .netrc to allow only yourself to read the file. Now you just type ftp ftp.yourdomain.com and then you’re logged in, without being prompted for either username or password.
To make it even easier, shorten ftp ftp.yourdomain.com to a single customized command!
Enter the following in a text file:
#!/bin/sh
ftp ftp.yourdomain.com
and save it to /usr/local/bin/ and call it whatever you like. Make it executable by applying chmod 700 /usr/local/bin/the_file — only you have access to it with those rights. If you named the file school, then you only have to type school in Terminal and you are automatically logged into ftp.yourdomain.com, provided you saved username and password in the .netrc file in your home directory.
[...] Related: Using ftp in Terminal without entering password [...]