LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   Connection to SSH closing immediately (https://www.linuxquestions.org/questions/linux-general-1/connection-to-ssh-closing-immediately-520565/)

scratched 01-18-2007 12:15 PM

Connection to SSH closing immediately
 
Since last night, a debian server I run in my basement has been refusing ssh connections. The first time it happened was last night when I tried to connect in from another linux machine using the X tunneling option. I assumed that it was just a problem with the X session option so I figured I'd mess with it the next day since it was already late.

Today I tried connecting from school using Putty on a windows machine and I get the error "Server Unexpectedly Closed the Connection"

As far as I know, I haven't made any changes to the server. I was using it early last night to do some php coding in Vim with no problems and then later that night it wouldn't let me through.

Does anyone have any ideas on how to fix this or troubleshoot it?

I'm still in school so I can't get to the machine directly, but I plan to mess with it when I get home.

ramram29 01-18-2007 02:51 PM

Try this from the server: 'ssh myusername@localhost'

If it lets you in then there's something wrong with your network or firewall.

If it does NOT let you in then there's something wrong with your configuration or your permissions.

scratched 01-18-2007 03:10 PM

I tried connecting to root@localhost, and the error I got was identical to the one I got connecting remotely from my linux laptop:
Quote:

ssh_exchange_identification: Connection closed by remote host
As far as I know, I haven't made any changes to the computer that would make me unable to connect. I never use the computer directly with its own monitor. I always connect using ssh. The first time it gave me problems was last night when I tried using X forwarding for the first time. That's the only thing I can think of that I've done differently.

Does anyone know what I can do to fix this problem or try to troubleshoot it?

anomie 01-18-2007 03:23 PM

Are you permitting root login in sshd_config? (Better that you're not permitting it. But that may be the simple reason why you can not log in. Try logging in as a normal user.)

What types of authentication are you allowing in sshd_config?

Do you have any tcp_wrappers (/etc/hosts.allow / /etc/hosts.deny) rules in place that would affect sshd?

scratched 01-18-2007 03:42 PM

I tried logging in as a regular user also. Still no luck. I usually never log in as root altogether but when I went onto the machine to try fixing the ssh problem I logged in as root for some reason.

The other problem I've found is that when I tried re-installing ssh there were a lot of packages that had errors/needed upgrading (2 of which were openssh-server and openssh-client), so I did a dist-upgrade, and there were problems processing 2 packages:
openssh-server and ssh

Here is a summary of the error I got when doing a dist-upgrade:
Quote:

Setting up openssh-server (4.3p2-8)...
/var/run/sshd must be owned by root and not group or world-writable.
invoke-rc.d: initscript ssh, action "restart" failed.
dpkg: error processing openssh-server (--configure):
subprocess post-installation script returned error exit status 1
dpkg: dependency problems prevent configuration of ssh:
ssh depends on openssh-server; however:
Package openssh-server is not configured yet.
dpkg: error processing ssh (--configure):
dependency problems - leaving unconfigured
Errors were encountered while processing:
openssh-server
ssh
And to answer anomie's question, I haven't added anything to /etc/hosts.allow or /etc/hosts.deny unless something was added automatically. As for the sshd_config, whatever the default is, that's what I've been using. I haven't made any changes to ssh myself.

ramram29 01-18-2007 04:49 PM

You have a problem with your ssh upgrade. Uninstall, then reinstall. Type the following:

dpkg -l | grep ssh

Make sure all the ssh packages are uninstalled. Then reinstall ssh.

apt-get remove --purge openssh-client openssh-server

apt-get install ssh

Restart then on the same machine run:

ssh root@localhost

Matir 01-18-2007 05:38 PM

Try "ssh -vv username@localhost". It will provide more detail as to when the error occurs.

scratched 01-18-2007 07:26 PM

Totally purging ssh and re-installing worked, thanks!

Quintin79 03-25-2007 11:49 PM

Hey there. i found this on the coLinux wiki. its great and it fixed it for me. ill post the link but the fix aswell because i noticed that URLs dont last long in the linux world. they keep moving things!

http://colinux.wikia.com/wiki/CoLinuxForDummies

basically theres a bug in the fs that comes with colinux

Quote:

Code:

Q: I get the following error when logging in with PuTTY:
"server unexpectedly closed network connection"
The error occurs when I press <enter> after typing in my password.
Anyone have an idea why?

This is a problem of the Debian rootfs that we use. I could solve this with:

Code:

"apt-get -u -o APT::Force-[[LoopBreak]]=true install libgcc1"



All times are GMT -5. The time now is 07:16 PM.