I have an FTP and FTPS server where I can connect to easily with FileZilla. I'm looking for a linux CLI method. I thought lftp does it, but it seems weird. Is there another way?

Here is the method I found on Google to connect to my FTPS with lftp. But I hope there is an easier way:

lftp -c 'open -e "set ftps:initial-prot ""; \
   set ftp:ssl-force true; \
   set ftp:ssl-protect-data true; \
   put test.txt; " \
   ftps://HOSTNAME:990 '

The code I got above looks like it will fail – haven't tried it yet as I don't like it, I know that the \ need to be at the end of the line.

I'm looking for a much simpler one liner. Here is how I connect from any FileZilla client and it works:


Also, this works:


6 Answers 6


I don't know whether this wasn't available on the 2013 version of lftp, but now you can simply do:


For example, to connect to host with user test, you only type the following:

lftp -u test

If by weird you mean a long command line with both types of quotes, just avoid it. Use a script and save a bookmark. There are probably no better ftp clients than lftp.

  1. save your lftp script in a file
  2. run lftp without any arguments
  3. source the script
  4. save a bookmark.
  5. delete rhe script (to get rid of the clear-text password)

Use the bookmark in the future. You'll have to figure out if ssl options are saved for the bookmark or if you have to persist those settings via a global lftp configuration file.

Sample script.

$ cat lftp.ssl.commands
user moo foopass
set ftps:initial-prot "";
set ftp:ssl-force true;
set ftp:ssl-protect-data true;
open ftps://HOSTNAME:990

Sample output.

$ lftp
lftp :~> source  lftp.ssl.commands
lftp HOSTNAME:~> dir
`ls' at 0 [Connecting...]

Or you can do this in a bash script:

lftp <<SCRIPT
set ftps:initial-prot ""
set ftp:ssl-force true
set ftp:ssl-protect-data true
open ftps://<hostname>:990
user <user> <password>
lcd /tmp
cd <ftp_folder_hierarchy>
put foo.txt

This shouldn't create any permanent lftp changes in /etc/lftp.conf, or ~/.lftprc, or ~/.lftp/rc


it will fail on some servers, because ssl settings should be passed before the open command not within it. example of working one:

lftp -c 'set ftp:ssl-allow true ; set ssl:verify-certificate no; open -u USERNAME,PASSWORD -e "cd /; mput LOCAL/PATH/TO/FILE/FILENAME.EXT; quit" HOST'

I tried to connect to Proftpd server with above config but it does not work.

But, when I try to connect with the following config, it works:

  1. Create a config file with vi:

    vi .lftprc
  2. Put the following content in .lftprc file:

    set ftp:ssl-auth TLS
    set ftp:ssl-force true
    set ftp:ssl-protect-list yes
    set ftp:ssl-protect-data yes
    set ftp:ssl-protect-fxp yes
    set ssl:verify-certificate no
  3. Connect to the server with:

    lftp username@hostname

And that's it!



Here you have: ftp-ssl

Per default tries to connect via SSL or TLS. It needs no particular options or settings. And if secure connection is not available performs a standard FTP connection.

ftp-ssl <Server IP address or Server Name>

For example, ftp-ssl or ftp-ssl lovedByJesus

An excerpt from the documentation:

ftp-ssl replaces normal ftp using SSL or TLS authentication and encryption. It interoperates with normal ftpd. It checks if the other side is also talking SSL or TLS, if not it falls back to normal ftp protocol.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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