Simple command to connect to FTPS server on Linux command line

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

lftp -u YOUR_USER HOST_ADDRESS

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

lftp -u test 192.168.1.50

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:

#!/bin/bash
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
exit
SCRIPT

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!