Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

--- Latest Edit -----------------------------------

Thanks to all who helped but I'm still stuck. I'm desperate now. Any other processes to restart besides the sshd? I don't know which directions to go to? Any other ideas?


For a few months I managed to connect fine with ssh but I had to enter my password every time. I now forgot how far I went with the initial setup of ssh and keygen.

Anyway yesterday I tried to install the keys properly and go through the setup instructions found on this page.

I have to say that I did not do the steps related to the firewall. Upon completion of this command:

/etc/init.d/ssh reload

I have since been unable to log in through the key or the password way. Luckily I still had an ssh terminal session open so I could still tinker with it but did not manage to fix it. The Internet connection got interrupted this morning so that session is gone. Here is what I get when I run the 'ssh -p 30000 -v myuser@mydomain.com'

OpenSSH_5.1p1, OpenSSL 0.9.7l 28 Sep 2006
debug1: Reading configuration data /Users/swamiatma/.ssh/config
debug1: Reading configuration data /etc/ssh_config
debug1: Connecting to ohlalaweb.com [173.45.225.154] port 30000.
debug1: Connection established.
debug1: identity file /Users/swamiatma/.ssh/identity type -1
debug1: identity file /Users/swamiatma/.ssh/id_rsa type 1
debug1: identity file /Users/swamiatma/.ssh/id_dsa type -1
debug1: Remote protocol version 2.0, remote software version OpenSSH_4.7p1 Debian-8ubuntu1.2
debug1: match: OpenSSH_4.7p1 Debian-8ubuntu1.2 pat OpenSSH*
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_5.1
debug1: SSH2_MSG_KEXINIT sent
Connection closed by 173.45.225.154

Thanfully Slicehost provides a console through their admin panel through which I can log on. Please help. First priority, how can I login anyway possible: enable telnet, ssh password login, etc ??

Answer to that emergency situation would be great. Next I'd like to go through the process of login through private/public key again. I guess I'll need some more understanding of the process first.

EDIT: Here is the message I got from the auth.log

Aug  7 10:14:39 ohlala sudo: pam_unix(sudo:session): session closed for user root                                       
Aug  7 10:15:24 ohlala sshd[20217]: error: Could not load host key: /etc/ssh/ssh_host_rsa_key                           
Aug  7 10:15:24 ohlala sshd[20217]: error: Could not load host key: /etc/ssh/ssh_host_dsa_key                           
Aug  7 10:15:24 ohlala sshd[20218]: fatal: No supported key exchange algorithms

Not sure what I can do about it.

EDIT 2: Following rkthkr's advice I regenerated the server keys and here is the new error message I got.

Aug  7 12:07:50 ohlala sudo: pam_unix(sudo:session): session opened for user root by deploy(uid=0)                      
Aug  7 12:07:50 ohlala sudo: pam_unix(sudo:session): session closed for user root                                       
Aug  7 12:08:51 ohlala sshd[20362]: error: Could not load host key: /etc/ssh/ssh_host_rsa_key                           
Aug  7 12:08:51 ohlala sshd[20362]: error: Could not load host key: /etc/ssh/ssh_host_dsa_key                           
Aug  7 12:08:51 ohlala sshd[20363]: fatal: No supported key exchange algorithms                                         
Aug  7 12:09:15 ohlala sudo:   deploy : TTY=tty1 ; PWD=/home/deploy ; USER=root ; COMMAND=/usr/bin/tail -f /var/log/auth
.log -n 25                                                                                          
Aug  7 12:09:15 ohlala sudo: pam_unix(sudo:session): session opened for user root by deploy(uid=0)                      
Aug  7 12:09:15 ohlala sudo: pam_unix(sudo:session): session closed for user root
share|improve this question

5 Answers 5

Looks like you have your server-keys missing/wrong permissions/corrupt:

Clue:

error: Could not load host key: /etc/ssh/ssh_host_rsa_key                   
error: Could not load host key: /etc/ssh/ssh_host_dsa_key

Permission should be owned by "root:root" and chmod 0600

To generate those keys:

ssh-keygen -f /etc/ssh/ssh_host_rsa_key -N '' -t rsa
ssh-keygen -f /etc/ssh/ssh_host_dsa_key -N '' -t dsa
share|improve this answer
    
Hi rkthkr. Thanks for your help. After regenarated the keys as indicated above I still can't login into my system. I pasted the new error message from the tail of the auth.log as Edit 2 of my question. –  allesklar Aug 7 '09 at 12:13

Have you double checked your sshd_config?

Port 30000
Protocol 2
PermitRootLogin no
PasswordAuthentication no
X11Forwarding no
UsePAM no
UseDNS no
AllowUsers demo <- Check this

Looking at your output and the slicedhost setup I would think you have AllowUsers set incorrectly as you seem to be getting instantly rejected by the server.

If you can do it through the console maybe remove the AllowUsers line (if I remember correctly that will allow all users to SSH in again) and set PasswordAuthentication back to yes to get over the immediate issue.

share|improve this answer
    
Thanks Mark. Removed AllowUsers line. I had already set PasswordAuthentication to 'yes'. I still have the same problem. Can't reload the ssh (server i guess). –  allesklar Aug 7 '09 at 8:45
    
So is the server not actually running if you do /etc/init.d/ssh status? –  Mark Davidson Aug 7 '09 at 9:02
    
I did manage to restart it with '/etc/init.d/ssh restart' and now the reload command works fine. So i guess it's running but '/etc/init.d/ssh status' does not seem to be a valid command. I still can't connect with password or in any way. Message is Connection closed by id.address –  allesklar Aug 7 '09 at 10:05
    
Hi Mark. I appreciate your effort. I just edit my question to add some error messages from the auth.log. Does this help? –  allesklar Aug 7 '09 at 10:19
    
Do the files /etc/ssh/ssh_host_rsa_key and /etc/ssh/ssh_host_dsa_key actually exist and do they contain the correct formated key aka -----BEGIN RSA PRIVATE KEY----- the key quite a few lines -----END RSA PRIVATE KEY----- –  Mark Davidson Aug 7 '09 at 10:58

Since you regenerated the keys, have you checked that the new ones have the correct permissions? sshd can (and usually will) consider the files unusable if their permissions are not correct.

-rw------- 1 root root 668 /etc/ssh/ssh_host_dsa_key
-rw-r--r-- 1 root root 601 /etc/ssh/ssh_host_dsa_key.pub
-rw------- 1 root root 531 /etc/ssh/ssh_host_key
-rw-r--r-- 1 root root 335 /etc/ssh/ssh_host_key.pub
-rw------- 1 root root 883 /etc/ssh/ssh_host_rsa_key
-rw-r--r-- 1 root root 221 /etc/ssh/ssh_host_rsa_key.pub
share|improve this answer
up vote 1 down vote accepted

Well, after spending much time on this, including with Slicehost tech support I decided to give up on setting key authentication and i'm back to using password authentication.

To be able to access my server with password again I had to revert the sshd.config file to its original configuration.

share|improve this answer

hmmn shouldn't ..

/etc/init.d/ssh reload

be ..

sudo /etc/init.d/ssh reload

?

otherwise you get ..

error: Could not load host key: /etc/ssh/ssh_host_rsa_key
error: Could not load host key: /etc/ssh/ssh_host_dsa_key

!

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.