Skip to content

Instantly share code, notes, and snippets.

@zanloy
Created September 24, 2014 11:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zanloy/477a802a600bfe114f3c to your computer and use it in GitHub Desktop.
Save zanloy/477a802a600bfe114f3c to your computer and use it in GitHub Desktop.
Regenerate SSH host keys
#!/bin/bash
#Tested in RedHat but should work in other distros.
#set -x
rm -f /etc/ssh/ssh_host_key
rm -f /etc/ssh/ssh_host_key.pub
rm -f /etc/ssh/ssh_host_rsa_key
rm -f /etc/ssh/ssh_host_rsa_key.pub
rm -f /etc/ssh/ssh_host_dsa_key
rm -f /etc/ssh/ssh_host_dsa_key.pub
ssh-keygen -t rsa1 -N '' -f /etc/ssh/ssh_host_key
ssh-keygen -t rsa -N '' -f /etc/ssh/ssh_host_rsa_key
ssh-keygen -t dsa -N '' -f /etc/ssh/ssh_host_dsa_key
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment