Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is it possible to copy files to my Linux machine from another Linux machine automatically with FTP? By "automatically," I mean that FTP would need to handle submitting a login/password combination, as well as copy files, on its own.

Both machines run Red Hat 5.1. I want to get, for example, the file /root/file from the second Linux machine onto my machine and put it under /var/tmp without entering any login/password manually.

I don’t have expect on my machine, and I don't want to use SSH authentication.

If this can't be done automatically by FTP, please suggest an alternate solution, such as a Python script.

share|improve this question
Use key based SSH authentication and SCP. – Daniel Beck Nov 14 '11 at 4:52
sorry I dont want to use SSH authentication – diana Nov 14 '11 at 4:58
up vote 4 down vote accepted

You can use the lftp client program and use an FTP script.

lftp supports the ~/.netrc configuration file, in which you can store your credentials:

machine <hostname> login <user> password <password>

You can store a sequence of FTP commands in a file and have lftp execute them, like:

open <hostname>
cd /var/tmp
put /root/file optional_new_filename

The path in cd is on the remote host, the first argument to put is the local file.

Then, just run

lftp -f <filename>
share|improve this answer

You can always store the credentials in a file and pass them as an argument to the script which is calling the FTP command, however I would recommend using SFTP (FTP over SSH) instead with key-based authentication as per my reply to another post. Key-based authentication is more secure and your data & login channels will be encrypted.

share|improve this answer
please give me example – diana Nov 14 '11 at 5:00
An example would largely depend on how you're trying to do the transfer and what you are doing. Your post didn't provide enough of those details for me to give a detailed example in return. – Garrett Nov 14 '11 at 5:01
all I want is to get the /root/file from linux2 machine and copy this file to my linux1 under /var/tmp without login=root/password=pass123 – diana Nov 14 '11 at 5:04
Setup SSH key auth and use rsync -e ssh in a simple Bash script to copy the file. E.g. rsync -avH -e ssh root@linux2:/root/file /var/tmp/ – Garrett Nov 14 '11 at 5:09
your example not good because need the password entering, the target is to login & password auto – diana Nov 14 '11 at 5:47

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.