31

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; " \
   -u "USERNAME","PASSWORD" \
   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:

ftps://username:[email protected]/

Also, this works:

ftps://username:[email protected]/
2

6 Answers 6

20

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
0
12

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...]
8

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

7

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'
6

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!

1
  • Thank you, this worked for me in Ubuntu connecting to an AzureWebApp via FTPS.
    – ehambright
    Mar 4 at 22:15
5

Simple

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 192.168.35.100 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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .