aspose file tools*
The moose likes Linux / UNIX and the fly likes How to automate the scp command? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » Linux / UNIX
Bookmark "How to automate the scp command?" Watch "How to automate the scp command?" New topic
Author

How to automate the scp command?

Srikanth Kumar
Ranch Hand

Joined: Jun 04, 2008
Posts: 36
Here i have a problem in copying a file from one unix machine to another using scp command.

when i tried to execute the following command
[code]
scp /usr/tmp/abc.txt <some other ip>:/usr/tmp/
[code]

i got the prompting message below.
[code]
The authenticity of host '<some other ip>' can't be established.
RSA key fingerprint is 1d:9d e e:5b:bb:ab:8e:ae:8c:87:fe:66:3f:c5:6b.
Are you sure you want to continue connecting (yes/no)?
[code]

I want to automate this process. is there any option or parameter do we need to pass along with this command? Or can we achieve this using shell script?

ZThanx in advance.


Srikanth Kumar
SCJP 5, SCWCD 5, SCDJWS 5
Charles Lyons
Author
Ranch Hand

Joined: Mar 27, 2003
Posts: 836
How about:
[ November 04, 2008: Message edited by: Charles Lyons ]

Charles Lyons (SCJP 1.4, April 2003; SCJP 5, Dec 2006; SCWCD 1.4b, April 2004)
Author of OCEJWCD Study Companion for Oracle Exam 1Z0-899 (ISBN 0955160340 / Amazon Amazon UK )
Srikanth Kumar
Ranch Hand

Joined: Jun 04, 2008
Posts: 36
No. it also does not work.
It still prompting yes/no option.

Any other parameters can achieve this?

help on this is appreciated.
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16145
    
  21

To get rid of the prompt, type "yes" and the host will be added to the ssh known_hosts file. You won't be asked again unless the security signature of either the client or server changes.

To avoid even being asked the question - and the password prompt, add a security certificate to the client's ssh configuration.

For details, check out the full documentation of the SSH (openssh) command
[ November 05, 2008: Message edited by: Tim Holloway ]

Customer surveys are for companies who didn't pay proper attention to begin with.
Philip Thamaravelil
Ranch Hand

Joined: Feb 09, 2006
Posts: 99
IMO you'll have to setup ssh keys between the machines..
this will allow you to ssh and scp from one machine to another without a password prompt/security prompt.

have a look here for some guidance..
http://pkeck.myweb.uga.edu/ssh/


I've written some scripts to do this automatically..if your interested in having them email me. philip@consultant-solutions.com

cheers

Philip
Pat Farrell
Rancher

Joined: Aug 11, 2007
Posts: 4659
    
    5

Originally posted by Philip Thamaravelil:
IMO you'll have to setup ssh keys between the machines..
this will allow you to ssh and scp from one machine to another without a password prompt/security prompt.


Actually, that's not the OP's problem. He just needs to connect once and accept the server's RSA key.

Doing the full setup is handy, but really is a secondary consideration.
Philip Thamaravelil
Ranch Hand

Joined: Feb 09, 2006
Posts: 99
The title of this thread is 'How to automate the scp command?'

You must setup keys in order to automate a scp file transfer.
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14274
    
  21

Philip T, please check your private messages for an administrative matter. You can see them by clicking My Private Messages.


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 8 API documentation
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: How to automate the scp command?