password - SFTP

Hi team,

I know if we need to transfer the files between between 2 servser, we use SFTP through key setup between 2 server.

currently There are some problems and we are not able to setup keys between servers.

How can i use password with SFTP for temporary solutions, so that the file transfer process become automate.

i know it can be done using ftp like...

 
ftp -nvi <servername><<"XX"
quote user <username>
quote pass <password>
prompt
lcd <path>
mput <filename>
bye
XX

But, current system is not accepting ftp and we should use only SFTP so i have changed from ftp to sftp like...

 
sftp -nvi <servername><<"XX"
quote user <username>
quote pass <password>
prompt
lcd <path>
mput <filename>
bye
XX

But it says invalid n option.

Can someone help me on how to use password with SFTP, so that it won't prompt for password?

Afaik there is no option to hand over a password non-interactive with sftp. I think it's either keys or interactive. Maybe you can use expect to hand over a password.

Hi Zaxxon,

We do not have "expect" utility installed on our system... is there any other way?

What is ur OS?

In Rehad Enterprise Linux, I could find a command 'lftp' which can be used to do SFTP and it can be used like 'ftp'.

You can use below command to check the availablity of 'lftp'.

whereis lftp

i guess there is no other way..
you must use public/private key pairs with sftp

Below script worked in RedHat Enterprise Linux.

host=10.1.1.1
user=testuser
passwd=testpwd
lftp<<EOF
open sftp://$host
user  $user $passwd
dir
EOF

I am using sunSolaris.... there no lftp :frowning: