Created
March 7, 2014 21:35
-
-
Save lorddoig/9420658 to your computer and use it in GitHub Desktop.
Regenerate server SSH keys
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -e | |
if [ "$(id -u)" != "0" ]; then | |
echo "This script must be run with administrator privileges." | |
exit 1 | |
fi | |
if [ -z "$(which ssh-keygen)" ]; then | |
echo "Required utility ssh-keygen does not appear to be installed." | |
exit 2 | |
fi | |
KEYGEN_CMD=`which ssh-keygen` | |
echo "Removing current server keys..." | |
rm -rfv /etc/ssh/*key* | |
echo "Creating RSA key..." | |
echo | |
$KEYGEN_CMD -q -t rsa -f /etc/ssh/ssh_host_rsa_key -N "" -C "" | |
echo "Creating DSA key..." | |
echo | |
$KEYGEN_CMD -q -t dsa -f /etc/ssh/ssh_host_dsa_key -N "" -C "" | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment