Operating System - HP-UX
1827262 Members
2415 Online
109717 Solutions
New Discussion

Re: Using scp in a script

 
Michael Elleby III_1
Trusted Contributor

Using scp in a script

I am trying to execute an SCP between two servers. The servers are configured with ssh of course, but when the script runs, as I have issued the command:

scp -v -q FILE USER@DESTINATION:/DIRECTORY

the script seems to hang.

I decided to write output of script to a file, and the only significant thing I see is that I see a "Host key verification failed", which makes me inclined to believe that I may have corrupt keys.

Any suggestions?

Thanx in advance.

Mike-
Knowledge Is Power
8 REPLIES 8
Donny Jekels
Respected Contributor

Re: Using scp in a script

Mike,

have you compiles scp yourself? if so did you turn on --with-scp-stats?

Please advise
Donny
"Vision, is the art of seeing the invisible"
Michael Elleby III_1
Trusted Contributor

Re: Using scp in a script

Donny-

All of this was already in place when I was asked to review the issue as it is a job being launched by Tivoli Workload Scheduler.

Mike-
Knowledge Is Power
Brian Bergstrand
Honored Contributor

Re: Using scp in a script

Actually, it is more likely the IP address of the server changed, or the server's key changed. This would then be out of sync with the info stored in the ssh key file and ssh would flag it as a possible attack.

The key files are stored in your home directory in the .ssh directory. There is one for ssh v2 and one for ssh v1 keys. These are just plain text files, so you can edit them and remove the offending host. Then reconnect with ssh to cache the key again and then scp should work.

HTH.
Massimo Bianchi
Honored Contributor

Re: Using scp in a script

Looks like you have not loaded the identification before starting the script.

I haven't a script at hand, but something like a

ssh-add

o the sourcing of the proper file will work.
I remember sourcing the agent.dat, but i don't remembr well.

Second, try manually the connection using

ssh -v user@host

it that works, then your keys are OK.

HTH,
Massimo
Donny Jekels
Respected Contributor

Re: Using scp in a script

Mike,

regenerate your keys for the client first then upload the new key. check your keys with a ssh connection.

let us know how its going,
Donny
"Vision, is the art of seeing the invisible"
Michael Elleby III_1
Trusted Contributor

Re: Using scp in a script

Hey guys-

Right now, the scp completes without incident when I execute it from the command line. The issue occurs when I attempt to run this script from within TWS.

I am still investigating and will keep you updated on my progress.

Mike-
Knowledge Is Power
Brian Bergstrand
Honored Contributor

Re: Using scp in a script

This may be an environment var problem then. If the script works fine from your shell, then you may need to export the SSH_AGENT and friends variables to the TWS environment. (Not sure what TWS is.)

I assume you are using ssh-agent so you your local keys are cached after being decrypted once. Otherwise you would need to enter your key passphrase everytime ssh/scp was run.
Massimo Bianchi
Honored Contributor

Re: Using scp in a script

That was Brian!

I checked: we use sh-agent, and every script loads:

~/var/opt/ssh/ssh-agent.dat

that contains the proper SSH variables to use the autentication.

Massimo