"Connection closed by remote host" while doing ssh to a solaris box

Hi All,

When i try to do ssh from a linux to solaris box its throughing "Connection closed by remote host". Please not that this error is not occuring every time i do ssh, it occurs at random timing( Mostly ssh is successful) - unfortunately my script which is doing ssh is falling at this time slot when ssh is not working. Please suggest me some solution for this....

Not enough information for us to give a good answer. For example, are trying to connect as root? Does your connect fail at the same time? Can you make other connections during the time when the script has problems? Did you check the network, sshd on the remote box?

can you change the script to have more debug info so that when it fails you can get why it failed.

Incase you are not interested in solving network issue and just want the script to work ... then try this ...

RR=22 # non zero
until [ "$RR" = "0" ]
do
  echo " trying "
  ssh user@BADhost "ls" 
  RR=$?
  sleep 50 # Just so that next try is done after some time. 
done

This could be a temp fix ... but it is always advised to check with n/w and solve the problem.

Thanks for replying...

  1. I am not trying this as root but ssh key for my account all in place.
  2. Connection fail timwe is varying.. for example one day my script is working fine and the other day it couldnt as it throw" connection closed by remote host" error whe it runs.
  3. Other connections are fine... problem occurs when we try to connect one solaris box alone

Network connection all everything is fine..... by 6:35 AM we are having problem and by 6:40 the problem is getting solved. And like this its repeating on various timing

There is something wrong on the one system. You need to have the sysadmin turn on
a lot more logging - i.e., change the syslog.conf and sshd_conf (LogLevel settings) files for that one server.

Intermittent problems like this are painful to resolve sometimes. This is really a sysdmin issue, if things are as you describe. I doubt that you can do much to resolve it.