Skip to content

Instantly share code, notes, and snippets.

@SmugZombie
Created May 18, 2017 17:12
Show Gist options
  • Save SmugZombie/7d201bd193a6036ec4b0a987fd60e324 to your computer and use it in GitHub Desktop.
Save SmugZombie/7d201bd193a6036ec4b0a987fd60e324 to your computer and use it in GitHub Desktop.
Set Random Hostname
# Hostname Randomizer
# Ron Egli
# Get Current Hostname
hostn=$(cat /etc/hostname)
# Generate new hostname
newhostpre="BreachCollector-"
newhostrand=$(strings /dev/urandom | grep -o '[[:alnum:]]' | head -n 12 | tr -d '\n')
newhost=$newhostpre$newhostrand
# Change hostname in /etc/hosts & /etc/hostname
sudo sed -i "s/$hostn/$newhost/g" /etc/hosts
sudo sed -i "s/$hostn/$newhost/g" /etc/hostname
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment