This is my standard SSH
setup based on stribika.github.io.
awk '$5 > 2000' /etc/ssh/moduli > "$HOME/moduli"
# Make sure there is something left
wc -l "$HOME/moduli"
mv /etc/ssh/moduli /etc/ssh/moduli.bak
mv "$HOME/moduli" /etc/ssh/moduli
When there are no moduli with a keysize > 2000
you should gereate a new set:
ssh-keygen -G /etc/ssh/moduli.all -b 4096
ssh-keygen -T /etc/ssh/moduli.safe -f /etc/ssh/moduli.all
mv /etc/ssh/moduli.safe /etc/ssh/moduli
rm /etc/ssh/moduli.all
Remove default ssh_host_keys
and gererate a new pair:
rm /etc/ssh/ssh_host_*key*
ssh-keygen -t ed25519 -f /etc/ssh/ssh_host_ed25519_key < /dev/null
ssh-keygen -t rsa -b 4096 -f /etc/ssh/ssh_host_rsa_key < /dev/null
Backup default configuration and copy mine:
mv /etc/ssh/ssh_config /etc/ssh/ssh_config.orig
mv /etc/ssh/sshd_config /etc/ssh/sshd_config.orig
cp $HOME/<git_repo>/ss{h,hd}_config /etc/ssh