1825729 Members
2766 Online
109687 Solutions
New Discussion

SFTP Scripts

 
SOLVED
Go to solution
Dewa Negara_4
Regular Advisor

SFTP Scripts

Hi All,

I am running SFTP using expect script below :

#!/usr/local/bin/expect
spawn sftp -b batchFile @
expect "password:"
send "\n";
interact

I have an issue on above script as the password need to be hard-coded in the script.

Is there any other way how to prevent it? Or How can we translate the script to another methods such as perl or C or shell, so I can avoid hard-code password?

I just want to mitigate the security risk because of hard-coded password.

Pls help. High score will be given.

Thanks and Best Regards,
Negara
Santos
2 REPLIES 2
Steven E. Protter
Exalted Contributor
Solution

Re: SFTP Scripts

sftp comes with another nice little product.

Its called scp

if you exchange public keys, you can scp a file from server to server with no risk. This also applies to Linux and other flavors of Unix running openssh.

I am attaching a word doc on how to exchange public keys. Its easy. You don't need X, you can do it with cat.

Do pay attention to the directory permissions.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Dewa Negara_4
Regular Advisor

Re: SFTP Scripts

Steven,

Thanks alot.

Actually for now I do not prefer to use public/private keys because of company's policy reasons. My customer is requesting to run SFTP in batch file without generating public/private keys. One of the solution is using expect script above, but it is needed to had-code the password in the script. Any idea?

Thanks alot.
Best Regards,
Negara
Santos