Skip to content

Instantly share code, notes, and snippets.

@tavinus
Created November 7, 2022 22:20
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 tavinus/53a3337bbbccedef8284162167c19efb to your computer and use it in GitHub Desktop.
Save tavinus/53a3337bbbccedef8284162167c19efb to your computer and use it in GitHub Desktop.
Delete and rebuild SSH keys for an instance
#!/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