Issues using ssh from crontab to run remote script from


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Issues using ssh from crontab to run remote script from
# 1  
Old 08-19-2005
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
# 2  
Old 08-24-2005
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..
# 3  
Old 08-24-2005
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
# 4  
Old 08-25-2005
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?
# 5  
Old 08-25-2005
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?
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Ubuntu

Run a script at remote server without ssh password

Hello, What I want to do is to run a file on remote server by running a script at localhost but script should not ask ssh password of my remote server when script is executed. Scenario1: To copy files from server2 to data server:$ scp -r root@server2_ip:/var/www/html/*.* /var/ When I enter... (6 Replies)
Discussion started by: baris35
6 Replies

2. Shell Programming and Scripting

Remote script over ssh execution issues.

If I execute below code I am able to get string from column8 and column10 about a process. serverA1$> ps -ef | grep rotate | grep 'config' | awk '{print $8" "$10}' /<Oracle_home>/ohs/bin/odl_rotatelogs -h:/<app_Home>/config/OHS/ohs1/component_events.xml_ohs1... (12 Replies)
Discussion started by: kchinnam
12 Replies

3. Shell Programming and Scripting

How to run commands on remote server using ssh password less authentication?

Hi, I need to run a script located in a directory on remote server by using ssh authentication from my local unix server. Can anyone help me in this. I have tried the below command. It worked for echo command but when i tried to open a file using cat command it is showing "cat: cannot open... (6 Replies)
Discussion started by: ssk250
6 Replies

4. Shell Programming and Scripting

Script fails to run properly when run from CRONTAB

Hello all, I'm trying to write a script to gather and send data and it works just fine at the bash command line, but when executing from CRON, it does not run properly. My scripting skills are pretty limited and there's probably a better way, but as I said it works at the command line, but... (12 Replies)
Discussion started by: rusman
12 Replies

5. HP-UX

Remote ssh execution and .profile issues

Greetings, i'm currently having issues in successfully executing a script from one server to other, and i'm cracking my nut in understanding why. Let's get started with the default info: Server A: briozzo@A:/home/briozzo $ uname -a HP-UX A B.11.31 U ia64 2787251109 unlimited-user license ... (3 Replies)
Discussion started by: nbriozzo
3 Replies

6. UNIX for Dummies Questions & Answers

how to use ssh to run shell script on a remote machine?

how to use ssh to run shell script on a remote machine? ssh user@remote sh ./script.unx i ran the above command ./script.unx HAS NOHUP COMMAND IN ITS BODY, I AM GETTING ERROR AS NOHUP NOT FOUND... i tried to run that script from remote server, its working fine do ineed to set... (6 Replies)
Discussion started by: only4satish
6 Replies

7. Shell Programming and Scripting

SSH Remote login to VIO's (padmin) and run oem_setup_env

Hello all, I have been trying to run commands that collect basic info from the VIO's The issue I am having is setting the env with the "oem_setup_env" after I login as "padmin". I usually do the following: ssh server command ssh root@server date , but I need to login set the env and... (0 Replies)
Discussion started by: dfezz1
0 Replies

8. Shell Programming and Scripting

Ability to run sas prog on remote server using SSH

Hi, I am trying to run a sas prog on a remote server using ssh. I have got the command that I am using in the below paragraph. With it, I was able to run shell scripts but when I tried 'sas' it errored out. I have got my keys exchanged so when I say ssh serverA I automatically connect to my... (4 Replies)
Discussion started by: coolavi
4 Replies

9. Shell Programming and Scripting

Trying to run a script over ssh, having issues with tty assignment

Hey folks! I'm trying to run a tcpdump command that monitors for possible malicious traffic. I want to be able to run this on any of several remote boxes that I monitor which all have different capture interfaces. I've gotten the script to the point where it logs into the box and attempts to run... (8 Replies)
Discussion started by: JASI
8 Replies

10. UNIX for Dummies Questions & Answers

Closing ssh when process run on remote

Hi! I currently run a very long script (two hour left...) on a remote computer through a ssh session. I wonder whats happend if I close the ssh session, or even, the terminal. Is the script running on remote will stop? Thanks for your answers, Tp (1 Reply)
Discussion started by: tipi
1 Replies
Login or Register to Ask a Question