Issues using ssh from crontab to run remote script from

I have a solaris9 x86 server using ssh as follows:
SSH Version Sun_SSH_1.0, protocol versions 1.5/2.0.

The remote server solaris9 sparc has exactly the same version ssh installed.

I am running a script on my server which includes the following command to run a script on the remote server:
ssh -v -v -v user@serverip "/usr/users/userdir/scriptname.sh" >/logs/testssh.log

When I run this from the command line it runs without any issues and the remote script is executed. However I have inserted my script to my crontab file and the ssh command is executed as I can see the process but it never completes. It does actually execute the remote script but ssh doesnt exit so I cannot continue processing my local script.

Below is the output from the -v -v -v debug.
Can anyone help?

ssh -v -v -v debug output:

SSH Version Sun_SSH_1.0, protocol versions 1.5/2.0.
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Rhosts Authentication disabled, originating port will not be trusted.
debug1: ssh_connect: getuid 100 geteuid 100 anon 1
debug1: Connecting to ipaddress [ipaddress] port 22.
debug1: Connection established.
debug1: identity file /home/user/.ssh/identity type 3
debug1: Bad RSA1 key file /home/user/.ssh/id_rsa.
debug1: identity file /home/user/.ssh/id_rsa type 3
debug1: identity file /home/user/.ssh/id_dsa type 3
debug1: Remote protocol version 2.0, remote software version Sun_SSH_1.0.1
debug1: match: Sun_SSH_1.0.1 pat ^Sun_SSH_1\.0
Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-Sun_SSH_1.0
debug1: sent kexinit: diffie-hellman-group1-sha1
debug1: sent kexinit: ssh-rsa,ssh-dss
debug1: sent kexinit: aes128-cbc,blowfish-cbc,3des-cbc,rijndael128-cbc
debug1: sent kexinit: aes128-cbc,blowfish-cbc,3des-cbc,rijndael128-cbc
debug1: sent kexinit: hmac-sha1,hmac-md5
debug1: sent kexinit: hmac-sha1,hmac-md5
debug1: sent kexinit: none
debug1: sent kexinit: none
debug1: sent kexinit:
debug1: sent kexinit:
debug1: send KEXINIT
debug1: done
debug1: wait KEXINIT
debug1: got kexinit: diffie-hellman-group1-sha1
debug1: got kexinit: ssh-rsa,ssh-dss
debug1: got kexinit: aes128-cbc,blowfish-cbc,3des-cbc
debug1: got kexinit: aes128-cbc,blowfish-cbc,3des-cbc
debug1: got kexinit: hmac-sha1,hmac-md5
debug1: got kexinit: hmac-sha1,hmac-md5
debug1: got kexinit: none,zlib
debug1: got kexinit: none,zlib
debug1: got kexinit: C,geo,lcttab,iso_8859_1,iso_8859_15,en_GB,en_GB.ISO8859-1,en_GB.ISO8859-15,en_GB.ISO8859-15@euro,en_IE,en_IE.ISO8859-1,en_IE.ISO8859-15,en_IE.ISO8859-15@euro,fr,fr.ISO8859-15,fr.UTF-8,fr_BE,fr_BE.ISO8859-1,fr_BE.ISO8859-15,fr_BE.ISO8859-15@euro,fr_BE.UTF-8,fr_BE.UTF-8@euro,fr_FR,fr_FR.ISO8859-1,fr_FR.ISO8859-15,fr_FR.ISO8859-15@euro,fr_FR.UTF-8,fr_FR.UTF-8@euro,nl,nl.ISO8859-15,nl_BE,nl_BE.ISO8859-1,nl_BE.ISO8859-15,nl_BE.ISO8859-15@euro,nl_BE.UTF-8,nl_NL,nl_NL.ISO8859-1,nl_NL.ISO8859-15,nl_NL.ISO8859-15@euro,nl_NL.UTF-8,en_US
debug1: got kexinit: C,geo,lcttab,iso_8859_1,iso_8859_15,en_GB,en_GB.ISO8859-1,en_GB.ISO8859-15,en_GB.ISO8859-15@euro,en_IE,en_IE.ISO8859-1,en_IE.ISO8859-15,en_IE.ISO8859-15@euro,fr,fr.ISO8859-15,fr.UTF-8,fr_BE,fr_BE.ISO8859-1,fr_BE.ISO8859-15,fr_BE.ISO8859-15@euro,fr_BE.UTF-8,fr_BE.UTF-8@euro,fr_FR,fr_FR.ISO8859-1,fr_FR.ISO8859-15,fr_FR.ISO8859-15@euro,fr_FR.UTF-8,fr_FR.UTF-8@euro,nl,nl.ISO8859-15,nl_BE,nl_BE.ISO8859-1,nl_BE.ISO8859-15,nl_BE.ISO8859-15@euro,nl_BE.UTF-8,nl_NL,nl_NL.ISO8859-1,nl_NL.ISO8859-15,nl_NL.ISO8859-15@euro,nl_NL.UTF-8,en_US
debug1: first kex follow: 0
debug1: reserved: 0
debug1: done
debug2: mac_init: found hmac-sha1
debug1: kex: server->client unable to decide common locale
debug1: kex: server->client aes128-cbc hmac-sha1 none
debug2: mac_init: found hmac-sha1
debug1: kex: client->server unable to decide common locale
debug1: kex: client->server aes128-cbc hmac-sha1 none
debug1: Sending SSH2_MSG_KEXDH_INIT.
debug1: bits set: 532/1024
debug1: Wait SSH2_MSG_KEXDH_REPLY.
debug1: Got SSH2_MSG_KEXDH_REPLY.
debug1: Host 'ipaddress' is known and matches the RSA host key.
debug1: Found key in /home/user/.ssh/known_hosts:1
debug1: bits set: 510/1024
debug1: ssh_rsa_verify: signature correct
debug1: Wait SSH2_MSG_NEWKEYS.
debug1: GOT SSH2_MSG_NEWKEYS.
debug1: send SSH2_MSG_NEWKEYS.
debug1: done: send SSH2_MSG_NEWKEYS.
debug1: done: KEX2.
debug1: send SSH2_MSG_SERVICE_REQUEST
debug1: service_accept: ssh-userauth
debug1: got SSH2_MSG_SERVICE_ACCEPT
debug3: input_userauth_banner

|-----------------------------------------------------------------|
| This system is for the use of authorized users only. |
| Individuals using this computer system without authority, or in |
| excess of their authority, are subject to having all of their |
| activities on this system monitored and recorded by system |
| personnel. |
| |
| In the course of monitoring individuals improperly using this |
| system, or in the course of system maintenance, the activities |
| of authorized users may also be monitored. |
| |
| Anyone using this system expressly consents to such monitoring |
| and is advised that if such monitoring reveals possible |
| evidence of criminal activity, system personnel may provide the |

evidence of such monitoring to law enforcement officials.

debug1: authentications that can continue: publickey,password
debug3: start over, passed a different list
debug3: authmethod_lookup publickey
debug3: authmethod_is_enabled publickey
debug1: next auth method to try is publickey
debug1: key does not exist: /home/user/.ssh/identity
debug1: try pubkey: /home/user/.ssh/id_rsa
debug1: read SSH2 private key done: name rsa w/o comment success 1
debug3: sign_and_send_pubkey
debug2: ssh_rsa_sign: done
debug2: we sent a publickey packet, wait for reply
debug1: ssh-userauth2 successfull: method publickey
debug1: fd 6 setting O_NONBLOCK
debug1: fd 7 setting O_NONBLOCK
debug1: fd 8 setting O_NONBLOCK
debug1: channel 0: new [client-session]
debug1: send channel open 0
debug1: Entering interactive session.
debug2: callback start
debug1: client_init id 0 arg 0
debug1: Sending command: /usr/users/userdir/test.sh
debug2: callback done
debug1: channel 0: open confirm rwindow 0 rmax 16384
debug2: channel 0: rcvd adjust 32768
debug1: channel 0: read<=0 rfd 6 len 0
debug1: channel 0: read failed
debug1: channel 0: input open->drain
debug1: channel 0: close_read
debug1: channel 0: input: no drain shortcut
debug1: channel 0: ibuf empty
debug1: channel 0: input drain->closed
debug1: channel 0: send eof
debug1: channel 0: rcvd eof
debug1: channel 0: output open->drain
debug1: channel 0: obuf empty
debug1: channel 0: output drain->closed
debug1: channel 0: close_write
debug1: channel 0: send close
debug1: channel: 0 rcvd request for exit-status
debug1: cb_fn 8066d92 cb_event 91
debug1: channel 0: rcvd close
debug1: channel 0: full closed2
debug1: channel_free: channel 0: status: The following connections are open:
#0 client-session (t4 r0 i8/0 o128/0 fd -1/-1)

debug1: channel_free: channel 0: dettaching channel user

Any SSH guru's out there that can lend a hand?

I had this type of issue before but the SSH versions were different on each server. This time they are the same but still having issues..

I'm in no way a "ssh-guru", so this is just a suggestion:

A script or command issued from the commandline inherits the environment of the login session, because it is a fork()-ed process. A cron-job has only the init-process (PID 1) as father and inherits nothing (init is notoriously poor on UN*X systems ;-)) ), so maybe problem is a PATH variable lacking or something such.

Solution in this case would be to create a file which sets a standard environment and source that in at the beginning of the script - this is good practice anyway and avoids all the hassles with broken/changed/nonexisting environments in scripts.

bakunin

Okay - so my script is a ksh script.. so if I use a ksh shell and type env..
Then output this to a file and source it in my script - you think this may help?

I did an env in my ksh environment - then I took the variable and put them all in my script.. Ran again from crontab - same result though. The process hangs.. as soon as I kill the ssh background process submitted from my script the rest continues..

Any other ideas?