LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   Passwordless connection to sftp server using lftp (https://www.linuxquestions.org/questions/linux-software-2/passwordless-connection-to-sftp-server-using-lftp-4175499381/)

aarelovich 03-25-2014 05:30 AM

Passwordless connection to sftp server using lftp
 
Hello. This is my first time writing to this forum and I thought this was the best place for this question. I apologize if it is not (I've read the guidelines).

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 allready 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?

Thank you for your time.

SAbhi 03-25-2014 07:43 AM

Quote:

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?
if you don't have the password!! NO
if admin have setup the authentication mechanism to prompt for the password the configuration would anyways look for it and reject your login unless you are privilaged for passwordless login by your admin.
however if you are an authorised user try this

aarelovich 03-25-2014 08:10 AM

Thanks for the reply. But I don't get it. The admin set it up so that I can login with my public key. Why is it different when using lftp?

szboardstretcher 03-25-2014 08:14 AM

You have to use a meaningless placeholder text:

Code:

lftp -u username,placeholder sftp://1.2.3.4
Additional info: http://matthewbotos.com/blog/2007/08...-keys-and-lftp

schneidz 03-25-2014 08:40 AM

seems like scp or sshfs would be easier in this context ?

aarelovich 03-25-2014 09:16 AM

Thank you so very much!!! That did the trick. For completion I'm posting my script for remote sychronization under this scenario.

Code:

lftp -f "
open -p port -u user,any_string_will_do sftp://server
mirror --no-empty-dirs  --only-newer --verbose $FTP_FOLDER $LOCAL_FOLDER
bye
"



All times are GMT -5. The time now is 06:30 PM.