Can a script runned in local server access remote server?

Hi,

Im creating a script that is supposed to run commands on remote server using sftp.

My script is as below:

#!/bin/ksh
sftp remote_server
mypassword
cd /u08/mydir/allfiles
mget *
..

But this is what I got when I runned the script:

Connecting to remote server...
Password:

It hangs at Password: without inputting the "mypassword" that I specied in the script. Anything that I can do to fix this? Please help :frowning:

The password can't be entered as in the sample script.

Depending on your sftp client, you can probably do something like:

sftp username:password@remote_server

Even better would be to create an ssh key and add it to the authorized_keys file in .ssh on the server. Then you wouldn't need a password at all.

Hi ShawnMilo..

Could you please explain more about authorized_keys file in .ssh on the server?
Which server do u mean, the local or remote?
and where do i find the .ssh file ?

I tried to do sftp username:password@remote_server but this is not working.

Thanks a bunch

Do some searching on this forum -- I'm sure it has been discussed a hundred times. Here are the keywords you want to search for:

authorized_keys
ssh-keygen