lftp with key + passphrase [closed]
Asked Answered
A

4

13

I'm using lftp to send files to an SFTP server, but I don't how to connect with key and passphrase.

So in sftp, I can do this:

sftp -i .ssh/id_rsa.mykey [email protected]
Enter passphrase for key '.ssh/id_rsa.mykey': my passphrase here

So, how can I use lftp with this connection method?

I have also tried:

lftp -e "set ssl:key-file .ssh/id_rsa.mykey" sftp://my.host.fr
Amoritta answered 20/7, 2012 at 9:58 Comment(0)
T
17

You must specify the username, and just pass anything as the password, to skip it asking.

lftp -u user,xxx sftp://...
Tactful answered 6/9, 2012 at 2:1 Comment(2)
lftp -u user, sftp://hostname also works (note the comma)Katabasis
For some reason, this does not work if you need to send a private key AND a password. The password is not sent, or it is not sent correctly.Contentious
C
24

An answer based off Jean-Luc Boss's and wiak's, but a bit more explicit:

To connect to a server, lftp uses an ssh command, by default ssh -a -x. It doesn't have an explicit option for changing the keyfile to use, but as you note, ssh does, so we just need to set lftp to connect using ssh -a -x -i <keyfile> before it connects.

You can do this in a few ways:

  • If you're using lftp's interactive command line, run the following command before you connect:

    set sftp:connect-program "ssh -a -x -i <keyfile>"
    
  • If you're specifying a bunch of commands to lftp using -c, just add that set command to the start of your command sequence:

    lftp -c 'set sftp:connect-program "ssh -a -x -i <keyfile>"; connect sftp://[email protected]; mirror -eR files; ...'
    
  • If you always going to want to use the same key, just add that set ... line from the first bullet to your ~/.lftprc file (or one of the other configuration file options listed in man lftp).

Cartography answered 4/9, 2014 at 20:9 Comment(1)
You must have a user that can connect throught SSH.Govan
T
17

You must specify the username, and just pass anything as the password, to skip it asking.

lftp -u user,xxx sftp://...
Tactful answered 6/9, 2012 at 2:1 Comment(2)
lftp -u user, sftp://hostname also works (note the comma)Katabasis
For some reason, this does not work if you need to send a private key AND a password. The password is not sent, or it is not sent correctly.Contentious
T
8

Just add:

set sftp:connect-program "ssh -a -x -i yourprivatekeyfile"

to your ~/.lftprc, as most of the settings can be set permanently there.

Tapir answered 30/10, 2013 at 5:54 Comment(0)
E
2

LFTP doesn't seem to pass or does not use the identity file specified with "ssl:key-file" with SSH. You have to specify it in the sftp:connect-program option:

ssh -a -x -i yourprivatekeyfile

This should work.

Efrainefram answered 22/7, 2013 at 9:1 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.