Created
November 7, 2022 22:20
-
-
Save tavinus/53a3337bbbccedef8284162167c19efb to your computer and use it in GitHub Desktop.
Delete and rebuild SSH keys for an instance
This file contains hidden or 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 | |
# This will delete and rebuild the SSH Keys of an instance | |
# Usefull if you clone CTs and VMs | |
sudo rm -v /etc/ssh/ssh_host_* | |
sudo dpkg-reconfigure openssh-server | |
sudo systemctl restart ssh | |
# You may need to reboot to fix weird issues | |
############################ | |
# To clean old keys on clients, you can use: | |
# ssh-keygen -R <HOSTNAME/IP> | |
# You will get errors if you don't clean the old keys | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment