Linux closing connection after successful login

I am working on a server with Debian 5.2.2. Barely having any administrative knowledge with Linux, I think I screwed something up. I used apt-get update and apt-get upgrade to get everything up to date and then I downloaded and installed Apache, PHP, and MySQL. Those tools seem to work fine, but now I can't even login to the server EXCEPT via local console. If I try to login via the GUI or if I try to login remotely via ssh, scp, or anything else, I get disconnected IMMEDIATELY upon successful login. In other words, it has no problem with the initial connection, but when I put in the correct username and password (for root or any user), I get disconnected. With the GUI, the screen goes black for a second and then puts me right back to the login prompt. With ssh, I get "connection to [server] closed." I tried WinSCP and I get "Connection has been unexpectedly closed. Server sent command exit status 254."

Any help is appreciated, and if there is any way I could give more information, please let me know. Thank you for your time.

Edits:

-- Any user can login on the local console

-- At the moment I don't have local access to the machine, so all I can do right now is ssh. Here is the output of ssh -vvv [server] after I enter my password:

Linux xxxxxxx.com 2.6.26.8+20091222+1056-debhawk-5.2.2-custom #1 SMP PREEMPT Tue Dec 22 10:58:57 EST 2009 i686

Last login: Mon Apr 30 14:48:07 2012 from xxxxxxx.com
debug2: channel 0: rcvd eof
debug2: channel 0: output open -> drain
debug2: channel 0: obuf empty
debug2: channel 0: close_write
debug2: channel 0: output drain -> closed
debug1: client_input_channel_req: channel 0 rtype exit-status reply 0
debug2: channel 0: rcvd close
debug2: channel 0: close_read
debug2: channel 0: input open -> closed
debug3: channel 0: will not send data after close
debug2: channel 0: almost dead
debug2: channel 0: gc: notify user
debug2: channel 0: gc: user detached
debug2: channel 0: send close
debug2: channel 0: is dead
debug2: channel 0: garbage collecting
debug1: channel 0: free: client-session, nchannels 1
debug3: channel 0: status: The following connections are open:
#0 client-session (t4 r0 i3/0 o3/0 fd -1/-1)

debug3: channel 0: close_fds r -1 w -1 e 6
Connection to xxx.x.xx.xx closed.
debug1: Transferred: stdin 0, stdout 0, stderr 35 bytes in 0.0 seconds
debug1: Bytes per second: stdin 0.0, stdout 0.0, stderr 3845.3
debug1: Exit status 254

Solution 1:

There are a couple of similar posts suggesting that this could be a problem with spawning a shell because of incorrect settings for the shell path in /etc/passwd

To check this, determine that your user shell path exists and is executable;

# cat /etc/passwd | grep tomh
tomh:x:1000:1000:Tom H:/home/tomh:/bin/bash <-- check this exists

Check shell exists:

# file /bin/bash
/bin/bash: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.32, stripped

also, check that the shell is not set to either /sbin/nologin or /bin/false, which would also block login, even with a successful authentication.

http://www.linuxforums.org/forum/ubuntu-linux/173779-solved-ssh-issue.html
http://www.unix.com/hp-ux/169496-solved-ssh-debug1-exit-status-254-problem.html
http://www.mail-archive.com/[email protected]/msg04460.html

Solution 2:

My problem was login user name directory was not available in the /home directory. So if you have a user called 'testuser' make sure the /home/testuser directory is available. Learned that from the /var/log/messages file.