Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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:password@ftp.server.com/

Also, this works:

ftps://username:password@ftp.server.com/
share|improve this question
    
You should probably separate this into two different questions, since they really are. – Taegost Jul 23 '13 at 16:50
    
Please read: How do I format my posts using Markdown or HTML?. – slhck Jul 23 '13 at 18:01

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...]
share|improve this answer

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

share|improve this answer

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
share|improve this answer

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'
share|improve this answer

You must log in to answer this question.

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