Sshd -t responds with unable to load host key even though host key exists

I’m in a confusing scenario with my sshd. When I run sshd -t (as mentioned by the arch wiki) I receive

Unable to load host key: /etc/ssh/ssh_host_rsa_key
sshd: no hostkeys available -- exiting.

even though it exists in the folder. Running ls /etc/ssh I get

moduli  ssh_config  sshd_config  ssh_host_dsa_key  ssh_host_dsa_key.pub  ssh_host_ecdsa_key  ssh_host_ecdsa_key.pub  ssh_host_ed25519_key  ssh_host_ed25519_key.pub  ssh_host_rsa_key  ssh_host_rsa_key.pub

The relevant section of my sshd_config is

# HostKey for protocol version 1                                                                                                                                                                                                          
#HostKey /etc/ssh/ssh_host_key                                                                                                                                                                                                            
# HostKeys for protocol version 2                                                                                                                                                                                                         
HostKey /etc/ssh/ssh_host_rsa_key                                                                                                                                                                                                         
#HostKey /etc/ssh/ssh_host_dsa_key                                                                                                                                                                                                        
#HostKey /etc/ssh/ssh_host_ecdsa_key                                                                                                                                                                                                      
#HostKey /etc/ssh/ssh_host_ed25519_key   

Note that the ssh_host_rsa_key is what is uncommented, but even when I’ve got them all commented out, it still raises an error. Any help would be appreciated

Are the permissions on /etc/ssh/ssh_host_rsa_key correct? It probably needs to be 600

What is the error when they are all commented out?

Also, are you running sshd -t as root? Because you won’t have access as a normal user.

Lastly, have you tried starting it with systemd instead? systemctl start sshd

Yeap! They are 600

Also, are you running sshd -t as root? Because you won’t have access as a normal user.

I was running it as a standard user … When I ran it as root everything worked. Thanks for your help!

Lastly, have you tried starting it with systemd instead? systemctl start sshd

Yeah, I was running it via sudo systemctl start sshd

1 Like

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.