Hi everybody,
I need some help on writing a script that is able to remote copy file to one server. I already created this types of scripts, and works ok as long as this server I want to copy from is access through telnet. Here is how I do it:
ftp -n xxx.xxx.xxx.xxx << _EOF_
user user_name password
cd $directory_path
ascii
prompt off
get file_i_want_to_copy
_EOF_
So you see that the input << allows the user name and password to be prompt.
The problem is when I try to do the same with the other servers that can be accessed only through ssh protocol. I tried to do this:
sftp -b batfile username@host
where my batfile contains:
password
cd $directory_path
get file_i_want_to_copy
quit
But still when I run the script it prompts for the password, and (after i enter the password) it says that there is no such file in such path....
I already sniffed around the net, and I already comprehend that sftp is mainly interactive, that the best way is to do it in a script is through scp with using a public/private key. But my problem is:
- With scp, instead of remote cp to the server where the script is runing, I have to write a script in the server I want to copy from
- I really rather not create a public/private key as root, but the files are accessible as root.
But right now, I�m open to suggestions, and in case there is no way to do this withouth the creation of a key, can you guys show me how to create this keys, and how it works??
There is still a lot of thing to learn in unix...... a lot!
Thanks for your time and help.
---------- Post updated at 05:29 PM ---------- Previous update was at 03:26 PM ----------
Hey guys, a little help please?? Kind of desperate here...
Thanks a lot