My ssh connection to my server works every 30 min for around 10 min.
Things that I figure out that might be the problem:
The server is underload (it is a database server), but on those spare moments that I can connect, it is still under the same load, which doesnt make sense.
The server is a ubuntu, and the consolekit was using a lot of virtual memory. Restarted the consolekit and it seems to be using a right amount of memory now.
It is not the host alows or deny. Those are setup properly.
It is not a firewall problem. Those settings were working and the same settings are working for other similar machines.
It is on the ec2. Amazon cloud.
You need to increase the logging level in
/etc/ssh/sshd_config
on the server and see if anything useful is in the logs under /var/logs after that. Also you should consider starting your sshd with-d
for debug mode and see if you can find anything interesting that way.Another good troubleshooting technique is to start sshd with -d and use
strace -p <pid>
to log the system calls made by your ssh servers. That could tell you if it's hanging on accessing a particular file for example.That often comes from an inability to write to the /var area of your system, we see this from time to time on our system, especially if /var goes to read only. check that via cat /proc/mounts ( use this not ANY other method as they can be fooled, this will not. )