Created
January 31, 2026 10:43
-
-
Save reski-rukmantiyo/48b4c7a87444909493d343a785351c85 to your computer and use it in GitHub Desktop.
Generate new Linux ID
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 | |
| # Run as root or with sudo | |
| # Machine ID | |
| rm -f /etc/machine-id /var/lib/dbus/machine-id | |
| systemd-machine-id-setup | |
| # SSH keys | |
| rm /etc/ssh/ssh_host_* | |
| ssh-keygen -A | |
| # Hostname (change as needed) | |
| read -p "Enter new hostname: " NEW_HOSTNAME | |
| hostnamectl set-hostname "$NEW_HOSTNAME" | |
| # Clean cloud-init if present | |
| if [ -d /var/lib/cloud ]; then | |
| cloud-init clean | |
| rm -rf /var/lib/cloud/instances/* | |
| fi | |
| echo "System IDs regenerated. Reboot recommended." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment