Sign up ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It's 100% free, no registration required.

I am recently working extensively with a remote system via ftp connection, since the session time is so short that I have to re-login quite often when I finish my work on my local machine, so I need a way to create a custom command/shell script to login to the ftp server with just one word, but the question is how to do it.


~$ ftp
 Name ( MyName
 Password: xxxx
share|improve this question
Just a question, why ftp and not ssh? ssh is much more secure and logging in like this would just be a simple bash alias – n0pe Sep 12 '11 at 17:32
Also, with SSH you can use authentication keys as well which will automatically log you in without having to store your username/pass in a .bashrc file as plain text. – sbtkd85 Sep 12 '11 at 17:41
well, I suppose the remote system has support for ssh, but it doesn't. – Rn2dy Sep 12 '11 at 17:49

3 Answers 3

up vote 4 down vote accepted

Usually, ftp command line clients support the configuration file ~/.netrc where you can configure credentials for remote systems, e.g.:

login juser
password keins

When you ftp then you don't have to retype this information anymore.

If you need to do more automation, you can script ftp via piping commands into it, e.g.:

$ cat
# complex logic to set
ftp <<EOF

Sure, if the system does not support ssh, it probably does not support ftps either - but you can try it (e.g. via ftp-ssl) if you need to secure your connection.

share|improve this answer

If you want to script out the whole thing:


quote USER $USER
put $FILE
exit 0

See also this web page.

share|improve this answer

If you want to automatically log in, you can use a .netrc file. I would NOT recommend this as you would have to store your username and password in plain text which is unsecure. If you can use ssh, then I'd recommend using that with authentication keys to automatically log you in.

If you cannot use a secure method such as ssh with keys, you can configure your ftp information by following this guide.

share|improve this answer

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.