ssh not ending (sometimes) from inside a script, why?

From: StillLooking (kimberly.lyons_at_nrl.navy.mil)
Date: 09/14/04


Date: 14 Sep 2004 09:58:23 -0700

Okay I have this script file that runs from cron job (on a unix box
running solaris 9 with SSH version Sun_SSH_1.0 protocols 1.5/2.0) and
most the time it works just find. Except every so often one of the
three ssh commands I have in the script just doesn't know it's done
and that of course causes the whole thing to hang!

The ssh command has executed. I can tell this because the command is
as follows:

ssh username@hostname "ls /somedirectory" >somedir.file

and a new somedir.file has been created on the machine running the
cron script.

Also, when this happens I can use the "kill sshprocessid" command and
the cron script will continue, fat dumb and happy!

The machine I'm "ssh"ing to is a unix box with OpenSSH_3.7.1p2
protocols 1.5/2.0, OpenSSL 0.9.6 on it.

I have tried running the ssh command in -v mode and looking at the out
put but can't really make much from it but can see a difference in the
order of things when the command hangs.

The –v output when ssh ended properly is as follows:

 1 -debug1: Entering interactive session.
 2 - debug1: client_init id 0 arg 0
 3 - debug1: Sending command: ls /Rawdata/Archive2/*VCID4.tlm.gz
 4 - debug1: channel 0: open confirm rwindow 0 rmax 32768
 5 - debug1: channel 0: read<=0 rfd 6 len 0
 6 - debug1: channel 0: read failed
 7 - debug1: channel 0: input open->drain
 8 - debug1: channel 0: close_read
 9 - debug1: channel 0: input: no drain shortcut
10 - debug1: channel 0: ibuf empty
11 - debug1: channel 0: input drain->closed
12 - debug1: channel 0: send eof
13 - debug1: channel 0: rcvd eof
14 - debug1: channel 0: output open->drain
15 - debug1: channel: 0 rcvd request for exit-status
16 - debug1: cb_fn 267a4 cb_event 91
17 - debug1: channel 0: rcvd close
18 - debug1: channel 0: obuf empty
19 - debug1: channel 0: output drain->closed
20 - debug1: channel 0: close_write
21 - debug1: channel 0: send close
22 - debug1: channel 0: full closed2
23 - debug1: channel_free: channel 0: status: The following
connections are open: #0 client-session (t4 r0 i8/0 o128/0 fd -1/-1)

24 - debug1: channel_free: channel 0: dettaching channel user
25 - debug1: Transferred: stdin 0, stdout 0, stderr 0 bytes in 0.6
seconds
26 - debug1: Bytes per second: stdin 0.0, stdout 0.0, stderr 0.0
27 - debug1: Exit status 0

The –v output when ssh hung is as follows:

 1 - debug1: Entering interactive session.
 2 - debug1: client_init id 0 arg 0
 3 - debug1: Sending command: ls /Rawdata/Archive2/*VCID4.tlm.gz
 4 - debug1: channel 0: open confirm rwindow 0 rmax 32768
 5 -debug1: channel 0: read<=0 rfd 6 len 0
 6 - debug1: channel 0: read failed
 7 - debug1: channel 0: input open->drain
 8 - debug1: channel 0: close_read
 9 - debug1: channel 0: input: no drain shortcut
10 - debug1: channel 0: ibuf empty
11 - debug1: channel 0: input drain->closed
12 - debug1: channel 0: send eof
13 - debug1: channel 0: rcvd eof
14 - debug1: channel 0: output open->drain
15 - debug1: channel 0: obuf empty
16 - debug1: channel 0: output drain->closed
17 - debug1: channel 0: close_write
18 - debug1: channel 0: send close
19 - debug1: channel: 0 rcvd request for exit-status
20 - debug1: cb_fn 267a4 cb_event 91
21 - debug1: channel 0: rcvd close
22 - debug1: channel 0: full closed2
23 - debug1: channel_free: channel 0: status: The following
connections are open: #0 client-session (t4 r0 i8/0 o128/0 fd -1/-1)

24 - debug1: channel_free: channel 0: dettaching channel user

Note I put the numbers on the trace.

I figure there is a race condition of some kind going on for the end
of command signal and once in awhile it gets missed but.... I just
don't know where else to look....

I'll take any ideas or comments, please!



Relevant Pages

  • Scripts using SSH and SSH_ASKPASS
    ... To test SSH scripts you better destroy the control TTY. ... The trick is to run YOUR script on YOUR local ... As for the password relaying command: this needs not be an X command. ... # we read one line from a temporary pipe. ...
    (comp.security.ssh)
  • Re: Nmon scheduling question
    ... command ran first then in the script is the ps and kill command so it ... Vince this is a great script. ... Cron Job with pid: 135238 Failed ...
    (AIX-L)
  • SUMMARY: cron entry: nth day of every month?
    ... cron can not handle this with its own syntax. ... 21st but "command" only runs if the output of the "date" command ... What I would suggest is rather than embedding the logic in each script ... The answer is it is _not_ possible to control it only with crontab ...
    (Tru64-UNIX-Managers)
  • Re: remote server backup script
    ... > Just type away at the command line. ... Make a backup of whatever you want ... > command line, in a script. ... >>the server ssh key on the clients machine). ...
    (comp.os.linux.misc)
  • Re: [PHP] SSH and php
    ... % % Is it possible to run a SSH command from php? ... it's possible to run any command from php. ... There are ways to do that -- I personally would create a kick script ...
    (php.general)