Comments on How to use the Linux ftp command to up- and download files on the shell
In this tutorial, I will show you how to use the Linux ftp command on the shell. I will show you how to connect to an FTP server, up- and download files and create directories. While there are many nice desktops FTP clients available, the ftp command is still useful when you work remotely on a server over an SSH session and e.g. want to fetch a backup file from your FTP storage.
17 Comment(s)
Comments
FTP is not secure, as it transmits usernames and passwords in plaint text. Anyone using a network sniffer can discover them.
No sensible site even enables FTP anymore.
Use SFTP or scp, but plesase DON'T use FTP...
Seems as if you haven't heard of FTPS yet. FTPS is FTP over SSL/TLS and all current FTP servers support FTPS, so FTP is a secure protocol when your server supports TLS and nobody can sniff any passwords as the connection is fully encrypted. just start the ftp connection with ftps://yourserver.tld instead of ftp://yourserver.tld and you are safe from password sniffing.
You might want to cover the ftp-ssl command as well, it's great for connecting to FTPS sites.
ftp-ssl -pivz secure "$FTP_HOST" 990
#you can automate this in a script too , just an example below, ofc one need to parameterize HOST USER FILE, to #be functional in a script eg with getopts or something
read -s -p "password:" passwd
function getfiles {
HOST='someftpserver'
USER='myftpuser'
FILE="somefile"
ftp -p -v -n $HOST <<END_SCRIPT
quote USER $USER
quote PASS $passwd
type binary
cd /go/to/some/dir
get $FILE
bye
END_SCRIPT
#exit 0
}
getfiles
How do you login if your usrname is an email address? For example "ftp [email protected]@ftp.ftpserver.org" won't work. Once ftp sees the @ it assumes the rest is the server address. Quotes, escape character \ and unicode @ don't work either.
Thank you for the FTP tutorial and I could easily follow it. Now would you be kind to let me know how to download sub directories like images, css, includes and so on...?
It was great to stumble upon this post.
Thank's ! <3
This was briliant. Succint, to the point, easy to skim, works. Thanks!
How can I to send a file via ftp using specific port automatically.
I tried of differet way but not work.
Ex,
ftp -n <ip> <<END_SCRIPT
quote USER
quote PASS
cd /path/dest
bin
prompt
put /dir/to/orig/file.txt
bye
END_SCRIPT
Sorry what will be command to get files by specific date. for example i want to dowload files which were uploaded in Dec 1 for example
To connect to the FTP server when we have domain name and port as well.We can use following command:
ftp domainName port
eg: ftp abc.int.pn 2121
How can I supress the output of the LCD command (because it is not usefull in log-file)?
How do you use the follwing command: put /path/fileIs the file name is something dynamic like : $(date -d yesterday +"%Y%m%d")_Admin_DEV.csv
After I enter the put command then the file path. I keep receiving "not a plain file" or I get "No containing directory". What am I doing wrong?
unable to open a .txt file from ftp...Please tell how to do that...The terminal says tat ia ma alerady connected to the ftp disconnect from there first....
Nice article..short and simple. Thank you