The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Advanced & Expert Users
Google UNIX.COM


UNIX for Advanced & Expert Users Advanced UNIX and Linux questions go here. Expert-to-Expert.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
AIX hangs on boot drchris AIX 6 01-11-2008 04:24 AM
ssh + clearcase hangs sunilav UNIX for Advanced & Expert Users 2 05-03-2007 02:53 PM
FTP Session Hangs Tux_Raju SUN Solaris 4 03-26-2007 11:19 AM
sqlplus session being able to see unix variables session within a script 435 Gavea Shell Programming and Scripting 2 07-03-2006 07:11 AM
AIX Hangs vipin77 AIX 5 07-22-2005 05:54 AM

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 11-09-2005
Registered User
 

Join Date: Mar 2005
Posts: 48
ssh session hangs

I need to run one script over few servers And I'm using cron to activate it.
What it does is to run few commands in each of these servers.
I use "ssh -n" with no problems
But a recently added new server doesnot act properly and my ssh call hangs there.
My calling servers' ssh version (Server AA)
OpenSSH_2.9p2, SSH protocols 1.5/2.0, OpenSSL 0x0090602f
The ssh version of the problematic server (Server AB)
SSH Version Sun_SSH_1.0, protocol versions 1.5/2.0.

But I dont think its a version problem because there are other servers likes of AB without any issue.

I ran the ssh command in debug mode and here is the result.
Please note the "^C" character because I had to press ^C to kill the hanged ssh session.

One more thing: If I use command like "df -k" instead of my script it works.
I even tried adding exit command at the end of my script with no result.
Please, if you have any clue to this issue share with me.

----output -----
$ /usr/local/bin/ssh -v -n myself@server1 /hta/home/myself/scripts/dr_err.sh
OpenSSH_2.9p2, SSH protocols 1.5/2.0, OpenSSL 0x0090602f
debug1: Reading configuration data /etc/ssh_config
debug1: Seeding random number generator
debug1: Rhosts Authentication disabled, originating port will not be trusted.
debug1: restore_uid
debug1: ssh_connect: getuid 122 geteuid 2 anon 1
debug1: Connecting to server1 [10.xxx.xx.xx] port 22.
debug1: temporarily_use_uid: 122/114 (e=2)
debug1: restore_uid
debug1: temporarily_use_uid: 122/114 (e=2)
debug1: restore_uid
debug1: Connection established.
debug1: identity file /hta/home/myself/.ssh/identity type 0
debug1: identity file /hta/home/myself/.ssh/id_rsa type 1
debug1: identity file /hta/home/myself/.ssh/id_dsa type 2
debug1: Remote protocol version 2.0, remote software version Sun_SSH_1.0.1
debug1: no match: Sun_SSH_1.0.1
Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_2.9p2
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-cbc hmac-md5 none
debug1: kex: client->server aes128-cbc hmac-md5 none
debug1: dh_gen_key: priv key bits set: 134/256
debug1: bits set: 506/1024
debug1: sending SSH2_MSG_KEXDH_INIT
debug1: expecting SSH2_MSG_KEXDH_REPLY
debug1: Host 'server1' is known and matches the RSA host key.
debug1: Found key in /hta/home/myself/.ssh/known_hosts2:127
debug1: bits set: 509/1024
debug1: ssh_rsa_verify: signature correct
debug1: kex_derive_keys
debug1: newkeys: mode 1
debug1: SSH2_MSG_NEWKEYS sent
debug1: waiting for SSH2_MSG_NEWKEYS
debug1: newkeys: mode 0
debug1: SSH2_MSG_NEWKEYS received
debug1: done: ssh_kex2.
debug1: send SSH2_MSG_SERVICE_REQUEST
debug1: service_accept: ssh-userauth
debug1: got SSH2_MSG_SERVICE_ACCEPT

***** This service is for authorised clients only *****

****************************************************************************
* Here contains the /etc/motd output *
****************************************************************************


debug1: authentications that can continue: publickey,password
debug1: next auth method to try is publickey
debug1: try pubkey: /hta/home/myself/.ssh/id_rsa
debug1: input_userauth_pk_ok: pkalg ssh-rsa blen 149 lastkey 105870 hint 1
debug1: read PEM private key done: type RSA
debug1: ssh-userauth2 successful: method publickey
debug1: fd 5 setting O_NONBLOCK
debug1: channel 0: new [client-session]
debug1: channel_new: 0
debug1: send channel open 0
debug1: Entering interactive session.
debug1: client_init id 0 arg 0
debug1: Sending command: /hta/home/myself/scripts/dr_err.sh
debug1: channel 0: open confirm rwindow 0 rmax 16384
debug1: channel 0: read<=0 rfd 5 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
--------------------------------------------------

-Here contains my script (dr_err.sh) output correctly-

---------------------------------------------------
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: client_input_channel_req: channel 0 rtype exit-status reply 0
debug1: channel 0: rcvd close
debug1: channel 0: is dead
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
^CKilled by signal 2.
debug1: Calling cleanup 0x2b23c(0x0)
debug1: Calling cleanup 0x33f18(0x0)
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 11-10-2005
Registered User
 

Join Date: Oct 2002
Posts: 670
You may need to patch your system. See this Sunsolve document.
Reply With Quote
  #3 (permalink)  
Old 11-20-2005
Registered User
 

Join Date: Mar 2005
Posts: 48
I got a solution to this.
Just add the following line at the end of the script you run on the remote server:
sleep 20 < /dev/null > /dev/null 2>&1 &

It should work.
Its known that ssh hangs when exiting and the above is just a workaround.
Reply With Quote
  #4 (permalink)  
Old 05-02-2008
Registered User
 

Join Date: Nov 2005
Posts: 28
ssh query

i run the following query but the ssh does not logout after complesion
(
echo "<some command"
sleep 2
echo "<command1>"
) ssh server1 > /tmp/out


but the ssh does not exit i have to press cntl+C to exit any help please .
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 09:31 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0