UPDATED HOWTO: Start Kali with a new hostname on every boot
I didn't want to revive an old / dead thread, but this was such a great idea it just needed a little updating.
tl;dr - reboot (or change) your hostname on every boot or by running a service command in order to avoid the detection of having a host named "kali-laptop" or "my_super_hacking_box"
I updated your script a little bit so that it will work with the latest Kali Rolling 2016.2 which uses systemd - I called mine changehost.sh
Code:
#!/bin/bash
cp -n /etc/hosts{,.old}
newhn=$(cat /dev/urandom | tr -dc 'A-Za-z' | head -c8)
hostnamectl set-hostname $newhn
echo "127.0.0.1 localhost" > /etc/hosts
echo "127.0.0.1 $newhn" >> /etc/hosts
exit
Then create a file called
Code:
/etc/systemd/system/changehost.service
In that file:
Code:
[Unit]
Description=Hostname Randomizer
[Service]
ExecStart=/usr/bin/changehost.sh
[Install]
WantedBy=multi-user.target
Finally you have to enable the service:
Code:
systemctl enable changehost.service
Now on boot your hostname should change as part of the services starting. You can also invoke it anytime with
Code:
service changehost start