How to give passwd along with sftp.

Hi,

I need to transfer files to remote host using sftp.

How to give pwd along with sftp.i.e while script runs it should not prompt for password.

sftp <username>@<hostname>

How to add passwd?

Thx

You have two choices, first one is to setup a key-based authentication between the appropriate users on the two systems involved, or the second is to download the source and compile the psftp and pscp clients. They are part of the putty family and will allow the password to be 'fed' in a manner similar to ftp.

But as always, remember that plaintext passwords in files are a bad idea.

depending on your implementations, sftp has a -b option. check your man page
example

sftp -b test.batch user@server.com

test.batch contains the following data.

      user_password
      get file
      quit

just an example. the rest you have to try on your own.

It's not working for me.
even i did same mentioned above

plz can body help me...

Log in as the User

Make sure you are in the Users Home Directory

pwd

Build the key

ssh-keygen -t rsa

(accept the defaul filename)
(leave the passphrase blank)

Change directory to ssh

On the Local machine...

cd .ssh

scp remote-host:.ssh/id_rsa.pub remote-host.key

cat remote-host.key >> authorized_keys

(Replace remote-host with server-name)

Once keys are built your sftp will not require a passphrase.

Hi Tmills,

Thanks for your post.. I have got my problem resolved.. :b: