I am trying to recreate the ssh-server host keys.
I have at least two ways to do this:
With dpkg-reconfigure
dpkg-reconfigure openssh-server
This works fine, but I cannot give the key length then. I want for example 4096 for the RSA key.
Manually with ssh-keygen
sudo ssh-keygen -f /etc/ssh/ssh_host_rsa_key -N 'myverylongpasswordhere' -b 4096 -t rsa
This recreates me the keys, but after restarting the server, I receive the following error message:
could not load host key: /etc/ssh/ssh_host_rsa_key
so I checked the sshd_config file whats in there:
HostKey /etc/ssh/ssh_host_rsa_key
matches perfectly. So, I checked the owner and rights to all my keys
-rw------- 1 root root 3326 Mär 24 08:57 ssh_host_rsa_key
When I remove all keys and recreate them with
dpkg-reconfigure openssh-server
, the keys are smaller and having the same file-rights like above.
Question: How can I use dpkg-reconfigure
with keylengh 4096 for RSA?
sshd
in debug mode from the command line (sudo sshd -d
) for more info on the issue and post the output.livewire@za20:/etc/ssh$ sudo sshd -d
outputsshd re-exec requires execution with an absolute path
Otherwise I would have included an example in my answer :(sudo /usr/sbin/sshd -d
. The error you got is meant literally (though not quite clear).dpkg-reconfigure
with keylength 4096? Is there a config file somewhere that contains this info? I looked around in the debconf databases (in/var/cache/debconf/
) but didn't find anything that looked like the keylength.RUN ssh-keygen -t ed25519 -f ~/.ssh/id_ed25519