You are not logged in.

#1 2013-06-18 08:17:52

JKAbrams
Member
From: Sweden
Registered: 2011-11-07
Posts: 81

[SOLVED] SSH: Could not load host key: /etc/ssh/ssh_host_rsa_key

SSH wont start after install:

# /usr/bin/sshd 
Could not load host key: /etc/ssh/ssh_host_rsa_key
Could not load host key: /etc/ssh/ssh_host_dsa_key
Could not load host key: /etc/ssh/ssh_host_ecdsa_key
Disabling protocol version 2. Could not load host key
sshd: no hostkeys available -- exiting.

I thought the installation would take care of key-generation as nothing is mentioned on the install section of the wiki SSHD.

Should the install section on the wiki contain a bunch of:

ssh-keygen <options>

In that case, what would be best practice options for default keys?

Something else that might be wrong with my system?

What I've tried so far:

# pacman -Rsn openssh
# rm -fr /etc/ssh
# pacman -S openssh

Last edited by JKAbrams (2013-06-18 14:11:27)

Offline

#2 2013-06-18 08:40:39

crondog
Member
Registered: 2011-04-21
Posts: 130

Re: [SOLVED] SSH: Could not load host key: /etc/ssh/ssh_host_rsa_key

You should start it via the systemd service because that will generate the keys

This will run /usr/bin/ssh-keygen -A

Offline

#3 2013-06-18 09:01:25

JKAbrams
Member
From: Sweden
Registered: 2011-11-07
Posts: 81

Re: [SOLVED] SSH: Could not load host key: /etc/ssh/ssh_host_rsa_key

crondog wrote:

You should start it via the systemd service because that will generate the keys

This will run /usr/bin/ssh-keygen -A

It does not seem to:

# systemctl start sshd
# systemctl status sshd
sshd.service - OpenSSH Daemon
   Loaded: loaded (/usr/lib/systemd/system/sshd.service; disabled)
   Active: failed (Result: start-limit) since ons 2013-06-19 08:49:49 NZST; 3s ago
  Process: 1705 ExecStart=/usr/bin/sshd -D (code=exited, status=1/FAILURE)

jun 19 08:49:49 mba systemd[1]: Starting OpenSSH Daemon...
jun 19 08:49:49 mba systemd[1]: Started OpenSSH Daemon.
jun 19 08:49:49 mba systemd[1]: sshd.service: main process exited, code=exited, status=1/FAILURE
jun 19 08:49:49 mba systemd[1]: Unit sshd.service entered failed state.
jun 19 08:49:49 mba systemd[1]: sshd.service holdoff time over, scheduling restart.
jun 19 08:49:49 mba systemd[1]: Stopping OpenSSH Daemon...
jun 19 08:49:49 mba systemd[1]: Starting OpenSSH Daemon...
jun 19 08:49:49 mba systemd[1]: sshd.service start request repeated too quickly, refusing to start.
jun 19 08:49:49 mba systemd[1]: Failed to start OpenSSH Daemon.
jun 19 08:49:49 mba systemd[1]: Unit sshd.service entered failed state.
# /usr/bin/sshd 
Could not load host key: /etc/ssh/ssh_host_rsa_key
Could not load host key: /etc/ssh/ssh_host_dsa_key
Could not load host key: /etc/ssh/ssh_host_ecdsa_key
Disabling protocol version 2. Could not load host key
sshd: no hostkeys available -- exiting.

But after running ssh-keygen -A manually, it works.

/usr/bin/ssh-keygen -A
ssh-keygen: generating new host keys: RSA1 RSA DSA ECDSA
# systemctl start sshd
# systemctl status sshd
sshd.service - OpenSSH Daemon
   Loaded: loaded (/usr/lib/systemd/system/sshd.service; disabled)
   Active: active (running) since ons 2013-06-19 08:53:28 NZST; 2s ago
 Main PID: 1715 (sshd)
   CGroup: name=systemd:/system/sshd.service
           └─1715 /usr/bin/sshd -D

jun 19 08:53:28 mba systemd[1]: Started OpenSSH Daemon.
jun 19 08:53:28 mba sshd[1715]: Server listening on 0.0.0.0 port 22.
jun 19 08:53:28 mba sshd[1715]: Server listening on :: port 22.

Offline

#4 2013-06-18 09:32:41

crondog
Member
Registered: 2011-04-21
Posts: 130

Re: [SOLVED] SSH: Could not load host key: /etc/ssh/ssh_host_rsa_key

Hmm not sure why it didn't work when running the service. But if it is working now please mark the thread as solved

Offline

#5 2013-06-18 11:14:15

JKAbrams
Member
From: Sweden
Registered: 2011-11-07
Posts: 81

Re: [SOLVED] SSH: Could not load host key: /etc/ssh/ssh_host_rsa_key

crondog wrote:

Hmm not sure why it didn't work when running the service. But if it is working now please mark the thread as solved

Yeah, it works for me now, thanks for your help, didn't know about the -A flag.
But I'm looking to fix the underlying problem here, if it indeed is a problem for more users and not just for me, I don't want to report a bug if I've just done something stupid...
Is is repeatable.

Offline

#6 2013-06-18 12:14:58

crondog
Member
Registered: 2011-04-21
Posts: 130

Re: [SOLVED] SSH: Could not load host key: /etc/ssh/ssh_host_rsa_key

I just removed the ssh_host* files from my system and then ran systemctl start sshd.service and it created the ssh_host_* files for me...So not sure why it didnt work for you...

Offline

#7 2013-06-18 14:10:52

JKAbrams
Member
From: Sweden
Registered: 2011-11-07
Posts: 81

Re: [SOLVED] SSH: Could not load host key: /etc/ssh/ssh_host_rsa_key

Ok, so I found out what causes this, turns out I DID do something stupid.
For some reason sshdgenkeys.service was already started before I tried to start sshd.service, this makes sshd.service fail and no keys are generated, so the solution is to make sure sshdgenkeys.service is stopped before trying to start sshd.service.
Marking this as SOLVED now.

Offline

Board footer

Powered by FluxBB