I can confirm that roneo.org's answer is right and TheStoryCoder's comment explaining how to specify the port also works.
I wanted a more secure login option that does not keep the credentials in a plain-text file like .netrc
and ensures my traffic is encrypted.
If lftp let you explicitly call the .netrc
file, you could just encrypt your .netrc
file with gpg
and pass it to lftp
. Like you can with cURL
.
Unfortunately, you cannot.
What you can do though is create an encrypted ftp url string that contains all your connection info including your password and pass it to lftp
.
Start by making a plain-text file containing a single string with the entire login, port and path to your server. Basically, what gets stored in your lftp
bookmarks file if you use it (~/.local/share/lftp/bookmarks
), only without the alias.
So, if your bookmarks
file has:
myftpserver ftp://<user>:<pass>@ftp.mysite.com:10234/path/to/files/
You are just going to use:
ftp://<user>:<pass>@ftp.mysite.com:10234/path/to/files/
First, make yourself a blank text file:
touch ~/.lftprc
Use a text editor to add that ftp url from your bookmarks
file so you keep your password out of your bash history:
vi ~/.lftprc
If you never setup gpg
, do that now:
gpg --full-generate-key
Then, encrypt that file with gpg
:
gpg -r <GPG USER ID/EMAIL> -e ~/.lftprc
The file then becomes ~/.lftprc.gpg
. Be sure to delete the file you made:
rm ~/.lftprc
Now you have your entire login url in basically an encrypted string that you can call using Bash
and gpg
:
lftp $( gpg --batch -q -d ~/.bookmark.gpg )
You can then turn this into an alias:
alias lftps='lftp $( gpg --batch -q -d ~/.bookmark.gpg )'
I chose lftps because it seemed cool, but you can do whatever you want:
HOSTNAME:~ # lftps
cd ok, cwd=/path/to/files
lftp <user>@ftp.mysite.com:/path/to/files>
My ftp server supports Explicit TLS over FTP so for the secure transfers, in my .lftp.conf
I have:
set ssl-allow true
set ssl:ca-file "/var/lib/ca-certificates/ca-bundle.pem"
set ftp:ssl-force true
So, after all that I wonder how lftp passes the user password to the server and if you can sniff that out...