# Funny sshd behavior -- connection closed

## adsmith

Funny sshd behavior:

This was noticed when my wife emailed me sayign she couldn't ssh in from work, saying "connection closed by $myhost"

I couldn't ssh in either, so I restarted sshd.

```
/etc/init.d/sshd restart
```

gives in auth.log

```

Oct 12 12:30:27 tock sshd[21075]: Received signal 15; terminating.

Oct 12 12:30:27 tock sshd[21075]: Received signal 15; terminating.

Oct 12 12:30:35 tock sshd[21164]: Server listening on :: port 22.

Oct 12 12:30:35 tock sshd[21164]: Server listening on :: port 22.

Oct 12 12:30:35 tock sshd[21164]: error: Bind to port 22 on 0.0.0.0 failed: Address already in use.

Oct 12 12:30:35 tock sshd[21164]: error: Bind to port 22 on 0.0.0.0 failed: Address already in use.

```

but, I can ssh in now.

Looking back in the logs, it was giving this same message a day or two ago, as well, when I rebooted for a kernel parameter change.

I haven't changed anything in /etc/ssh/sshd_config in a long time, and it shows no diff with an old backup.

So there are two problems:

(1) ssh suddenly stopped working -- very disconcerting!

(2) funny logs, possibly unrelated.

ideas?

----------

## viperlin

not sure why it stopped working but the logs show that the sshd was running, or at least something was using port 22, so i guess sshd MAY have crashed and kept the port locked. restarting it killed the crashed PID and started a new one... strange indeed.

----------

## hanj

I'm thinking it is related to the new glibc emerge. I had the same problem with SSH directly after glibc update. Apache is showing errors in logs, restarting the services seemed to have fixed that as well.

```

/usr/sbin/apache2: relocation error: /lib/libnss_dns.so.2: symbol __res_maybe_init, version GLIBC_PRIVATE not defined in file libc.so.6 with link time reference
```

Here is another thread talking about it:

https://forums.gentoo.org/viewtopic.php?t=236028&highlight=glibc

hanji

----------

## kashani

I'm liking the glibc theory. Had the exact same problem with ssh on two boxes the day I updated them. Got one rebooted and it's been fine for the past two days. The other I'm waiting on a admin to restart ssh from the console to see if that fixes it. 

kashani

----------

## hanj

I'm really surprised that the forum isn't going crazy with this problem. There is 'some' chatter about it.. but you'd think people would be freakin' that they can't access their boxes.

h

----------

## Borgond

hi there!, 

same over here - i started a emerge -U world on my remote server, now it is closing the ssh connection in the strange way described here  :Sad: 

remote & weekend are sure a bad combination ...  :Sad: 

hope I can reach someone to reboot the machine ... 

so long, 

   Borgond

----------

## bombcar

glibc was the culprit. As soon as I emerged it it stopped receiving ssh connections.

But my currently open one is still alive.....   :Twisted Evil: 

----------

## indanet

Same problem here, restarting sshd solved the problem.

One strange thing though: Only remote connections were automatically disconnected, connections from machines in the same network were still accepted.

Best regards

indanet

----------

## epretorious

This appears to be a known-issue. There's already a bugreport filed.

----------

## drutten

does restarting sshd solve the problem for good or will you still be disconnected after a while and have to restart sshd again?

----------

## Fr0d083

does anyone know if this could also affect bind? I had a name server working perfectly and just came in after the weekend and it doesn't work anymore. It has been working previously for about 1 year.

----------

## shade266

has anyone come up with an answer in regards to having sshd restarted before reconnection is available? Also,  *Quote:*   

> ct 12 12:30:35 tock sshd[21164]: error: Bind to port 22 on 0.0.0.0 failed: Address already in use.
> 
> Oct 12 12:30:35 tock sshd[21164]: error: Bind to port 22 on 0.0.0.0 failed: Address already in use. 

  kinda scares me.. if it's not me who is is connected, then who the hell is it?

----------

## shade266

apologies for my inane post above... a simple restart and edit of ssh_config and I was all right.

----------

## drutten

so how do I have to edit sshd_config? I had problems before with my server, but now on a new install on another computor I can't gett ssh to work, in any direction ( in our out ).

I've tried restarting sshd, rebooting and almost re-emerging, but I didn't have time for that, might try it next time it's available.

Any suggestions?

----------

