# Can't start sshd/no ssh_host_key

## alfalfa

Hello all, I just installed Gentoo and can't seem to ssh into or out of my machine.  I noticed that sshd isnt' running (go figure), but when I try to start it manually, I get:

sshd

Could not load host key:  /etc/ssh/ssh_host_key

Disabling protocol version1.  Could not load host key

Disabling protocol version2.  Could not load host key

sshd:  no hostkeys available -- exiting

Ok, ok I get the point, I need a host key, but how to generate that?  It's a binary file on my other computer, so I take it I can't just 'nano /etc/ssh/ssh_host_key' or something like that.  How did the rest of you do it?

----------

## rac

ssh-keygen

----------

## UnderScore

in /etc/init.d/ you will find a script called sshd which is used to bring up/down sshd. try executing that script: 

/etc/init.d/sshd start

The script contains bash code to check to see if you have a host key and then it creates them for you.  It actually alls the ssh executable ssh-keygen with a bunch of appropriate options. 

Use

man ssh-keygen

to get an idea how this works. and then peak at /etc/init.d/sshd to see how that script works.

I hope this helps.

James

_

----------

## alfalfa

I did the ssh-keygen thing (forgot to mention that in the first post), but no additional files were generated in /etc/ssh.  Until I restarted the computer that is  :Very Happy:   Doh!  Thanks so much for responding, and especially so quickly.  I'm an instant gratification kind of guy.

----------

## alfalfa

I still get error messages on startup about a missing key for ssh2, so it's not starting up or something.  When I did ssh-keygen, I specified -t as dsa.  I thought that was the protocol for ssh2.  Anyone know how I'd go about getting ssh2 running?  Thanks

----------

## rac

Please post the error message; it may just be that it is disabling protocol 1, which is not all together a bad idea.  Is your server's host key in /etc/ssh/ssh_host_dsa_key?  What settings do you have for HostKey and Protocol in /etc/ssh/sshd_config?

----------

## alfalfa

It doesn't say guru next to your name for nuthin'.  I checked /etc/ssh/sshd_config, and sure enough, I had this:

# HostKeys for protocol version 2

#HostKey /etc/ssh/ssh_host_rsa_key

#HostKey /etc/ssh/ssh_host_dsa_key

When I uncommented 'HostKey /etc/ssh/ssh_host_dsa_key', killed and restarted sshd, the error message went away.  Thank you so much, I'm so glad that there is a place such as this that I can go to get my questions answered when I'm stumped.

----------

