2

I'm running the following script that uses lftp:

lftp -f "
open sftp://myuser@sftp_server:443
lcd $FTP_FOLDER
mirror --no-empty-dirs  --only-newer --verbose $FTP_FOLDER $LOCAL_FOLDER
bye
"

Now If I've already passed my public key to the server administrator so if do this in the command line:

sftp -P 443 myuser@sftp_server

I get connected and I get the sftp prompt. When I do this the pwd command tells me that the folder that I need to sync has the path "/0Datos" and that is the value of $FTP_FOLDER.

When I execute the script I get this:

    source: Is a directory
    Password: 

Is there any way to connect without the server asking me for a password (I don't have it) in order to sync the folder 0Datos to a local folder of mine?

andrew.46
  • 132
  • 1
  • 8
aarelovich
  • 5,140
  • 11
  • 55
  • 106

2 Answers2

1

Just supply an empty password in the URL:

open sftp://myuser:@sftp_server:443

lftp asks for the password before connecting to the server, but if the server does not require one lftp does not send it.

lav
  • 1,351
  • 9
  • 17
1

Add a colon after your username (myuser:@ instead myuser@)

sftp://myuser:@sftp_server:443

This will mean no password (empty password).

ltvn
  • 69
  • 1
  • 1
  • This is also required if you have set up an ssh key pair for remote login and you don't want to enter the password for your lftp sftp session. – Christian Herenz Dec 07 '22 at 17:16