copy file from script file to remote computer


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting copy file from script file to remote computer
# 1  
Old 10-31-2008
MySQL copy file from script file to remote computer

hi,
i want copy one or group of file from a computer to others, but i have some problem that do not allow me to do this.
i do this by scp command like this :

Code:
scp <file name> root@cpName:destinationAddress

but the problem is that it do not it automatically. it means when it is connecting to the destination computer, it ask me a "yes/no" question and after that it request the root password.
now i want know that how can i answer these questions by writing scripts

Regards,
M.Shirzadi
# 2  
Old 10-31-2008
It should only ask the yes/no the first time.

1. Suppose the domain name of your server is server, and your login name loginname.

2. On the client, generate a public and private key.
ssh-keygen -C loginname@server -t dsa

When asked for a password, simply press return. The private key is stored in ~/.ssh/id_dsa, and the public key in ~/.ssh/id_dsa.pub.

Never give the private key away!

3. Copy the public file to the server with
scp ~/.ssh/id_dsa.pub loginname@server:~/

4. Login on the server with
ssh loginname@server

append the copied file to ~/.ssh/authorized_keys with

cat ~/id_dsa.pub >>~/.ssh/authorized_keys

5. If you want to enable this features on other servers, just repeat step 3 on each of the servers.
That’s it! If you have done everything correctly, the next time you login via SSH or use CVS over SSH, you will not need to enter a password yet you have a secure connenction.
# 3  
Old 10-31-2008
One thing is to write a shell script that will take input until the end of input is reached. use the << !! shell parameters on the line to tell it to receive input from the script until you reach the !!. So if I wanted to supply input I would write a shell such as
scp <FILENAME> User@remotehost << !!
yes
Username
Password
!!
But if you want to do this multiple times then setup the server side so you can login using a public/private keys without being prompted to do so.
# 4  
Old 10-31-2008
thanks for your attention
my friend IKON.
i do your suggestion but i couldn't login to my client.means it again ask me password, also i restart my ssh on client,but it doesn't change.
what's your idea. what is my problem.
thanks
# 5  
Old 11-01-2008
I just ran the exact instructions on my new servers, CentOS 5.2 I installed today and it worked perfectly.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Copy a file from local host to a list of remote hosts --- perl script

Hi friends, i need to prepare a script ( in perl) i have a file called "demo.exe" in my local unix host. i have a list of remote hosts in a file "hosts.txt" now i need to push "demo.exe" file to all the hosts in "hosts.txt" file. for this i need to prepare a script(in perl, but shell... (5 Replies)
Discussion started by: siva kumar
5 Replies

2. UNIX for Advanced & Expert Users

How to copy a file from remote server and preserve timestamp

Hi How to copy a file from remote server and preserve timestamp. Please not, i have to pass username and password to connect to the remote server in the shell script. Can this be achieved with simple ftp ? are there any options in ftp ? Thanks (4 Replies)
Discussion started by: skumar75
4 Replies

3. Shell Programming and Scripting

Copy a file on remote servers

Hey Unix Gurus, I'm having trouble in copying a file on 5 different servers, first how can you do it locally (i.e without the need to ssh to the server you want to copy the file) and if you need to ssh how do u run a command within that server. Please see my code below(it doesn't work somehow).... (10 Replies)
Discussion started by: sexyTrojan
10 Replies

4. Shell Programming and Scripting

copy the latest file in the remote server's directory

Hi Expert Team, I performed the below piece of code to copy the latest file in the remote server's directory to the same server's other directory. But it is not working properly. How can i handle this? Can you please help me..? ssh ${REMOTE_USERID}@${REMOTE_HOSTNAME} "cp -p `ssh... (3 Replies)
Discussion started by: spkandy
3 Replies

5. Shell Programming and Scripting

tail copy of a file to remote location

Hello, I have a solaris box and a windows server. The windows server runs cygwin for ssh service. I have an audit log in solaris box. When ever new records are added to the log file, this delta has to be trasported to a remote file in windows. I can do a ssh once in a while, but want the... (7 Replies)
Discussion started by: unori
7 Replies

6. UNIX for Dummies Questions & Answers

Copy file from Remote Unix box to windows machine

Hi I need to copy a file from the remote unix server to windows machine. I read lot of thrad but didn't worked out. Requesting all to please help. (2 Replies)
Discussion started by: sameerspice
2 Replies

7. Shell Programming and Scripting

Copy a file on remote server

I have ssh keys setup and running properly between two servers. I have a Korn shell script that is logging into the remote server and needs to backup the authorized_keys and/or authorized_keys2 files. The following syntax works perfectly ------------------------------------- ssh... (1 Reply)
Discussion started by: sunsysadm2003
1 Replies

8. HP-UX

help me to copy remote file

I want to copy dump generated from oracle database to my local DAT drive. Currently I am copying remote file to local drive thru rcp command and later copy it to local DAT. Pls. help me in this. Thanks Man Mohan email address removed (8 Replies)
Discussion started by: manmohan73
8 Replies

9. UNIX for Advanced & Expert Users

remote file copy across 2 systems (AIX and SCO)

Hello, Pls i need to copy some data from AIX Unix 4.3 to a SCO Openserve 5.0.5 using rcp command. But i keep on having permission error. WHAT IS THE SOLTION OR WHAT COMMAND CAN I USE AGAIN (4 Replies)
Discussion started by: aji
4 Replies

10. UNIX for Dummies Questions & Answers

Remote file copy

I facing a problem with Unix command "rcp". I unable to perform a rcp between host machines. I have religiously followed the man pages, but still unable to solve the problem. Do i check for anything to perform this command? Pls help....thanks =) (3 Replies)
Discussion started by: lchunl
3 Replies
Login or Register to Ask a Question