PDA

View Full Version : HOW TO: Start Kali with a new unique hostname for each boot



testingresults
2013-05-07, 05:36
Given the popularity of this distro, seeing a computer named "kali" on a netowrk may raise a red flag. So, here is a way to avoid appearing as such:

To get situated, open a terminal and cd to your root directory:

cd ~

STEP 1: Create a script which will automate the procedure


In this terminal create a file.

touch newhostname
leafpad newhostname
Now, add the following lines to your newly created file:


#!/bin/bash

cp -n /etc/hosts{,.old}

newhn=$(cat /dev/urandom | tr -dc 'A-Za-z' | head -c8)
echo $newhn > /etc/hostname

echo "127.0.0.1 localhost" > /etc/hosts
echo "127.0.0.1 $newhn" >> /etc/hosts
cat /etc/hosts.old >> /etc/hosts
service hostname.sh stop
sleep 1
service hostname.sh start
xhost +$newhn
exit

Save it and exit leafpad.


STEP 3: Make it run at boot

Store it:

mv newhostname /usr/bin/newhostname
Make it executable

chmod +x /usr/bin/newhostname


Make it run at startup:

--Click on "Applications" --> "System Tools" --> "Preferences" --> "Startup Applications"
--Click "Add"
--Fill in:
----Name: New Host Name
----Command: /usr/bin/newhostname
----Comment: Start Kali with a different hostname each boot


http://i.imgur.com/ysag6A8.png

-Click Save
-Clost Windows

All done!

Chaos
2013-06-17, 05:25
Nice Idea :cool:

Have taken all steps as described but for me it does not work.
The symlinks in rc2.d to rc5.d are also different to the "normal" system symlinks
The "system" symlinks...


0 lrwxrwxrwx 1 root root 20 Jun 17 04:40 S19pulseaudio -> ../init.d/pulseaudio
0 lrwxrwxrwx 1 root root 18 Jun 17 04:40 S20bootlogs -> ../init.d/bootlogs
0 lrwxrwxrwx 1 root root 18 Jun 17 04:40 S21rc.local -> ../init.d/rc.local
0 lrwxrwxrwx 1 root root 19 Jun 17 04:40 S21rmnologin -> ../init.d/rmnologin


And the symlinks of the loop


0 lrwxrwxrwx 1 root root 23 Jun 17 07:10 S27newhostname -> /etc/init.d/newhostname

I've tried to change /etc/init.d/ to .. /init.d/ but it will end in a "File dosent exist" error...

Do you have any advice what I can do?

P.S
sorry if something was not easy to understand my english is not really good
but i will try my best :)

testingresults
2013-06-18, 17:53
Nice Idea :cool:

Have taken all steps as described but for me it does not work.
The symlinks in rc2.d to rc5.d are also different to the "normal" system symlinks
The "system" symlinks...


And the symlinks of the loop

I've tried to change /etc/init.d/ to .. /init.d/ but it will end in a "File dosent exist" error...

Do you have any advice what I can do?

P.S
sorry if something was not easy to understand my english is not really good
but i will try my best :)


Apparently an update changed how startup scripts are run. Here, do this:


for i in {2..5}; do rm /etc/rc"$i".d/S27newhostname; done
rm /etc/init.d/newhostname

Then follow the modified steps found in the original post now. This should work, but I'll update the post with something cleaner soon.

Chaos
2013-06-19, 12:14
:) :) :)

Thank You very much now it works perfect.
Have a nice day.

Greetings
Chaos

ztech
2013-12-02, 08:52
Given the popularity of this distro, seeing a computer named "kali" on a netowrk may raise a red flag. So, here is a way to avoid appearing as such:

To get situated, open a terminal and cd to your root directory:

cd ~

STEP 1: Create a script which will automate the procedure


In this terminal create a file.

touch newhostname
leafpad newhostname
Now, add the following lines to your newly created file:


#!/bin/bash

cp -n /etc/hosts{,.old}

newhn=$(cat /dev/urandom | tr -dc 'A-Za-z' | head -c8)
echo $newhn > /etc/hostname

echo "127.0.0.1 localhost" > /etc/hosts
echo "127.0.0.1 $newhn" >> /etc/hosts
cat /etc/hosts.old >> /etc/hosts
service hostname.sh stop
sleep 1
service hostname.sh start
xhost +$newhn
exit

Save it and exit leafpad.


STEP 3: Make it run at boot

Store it:

mv newhostname /usr/bin/newhostname
Make it executable

chmod +x /usr/bin/newhostname


Make it run at startup:

--Click on "Applications" --> "System Tools" --> "Preferences" --> "Startup Applications"
--Click "Add"
--Fill in:
----Name: New Host Name
----Command: /usr/bin/newhostname
----Comment: Start Kali with a different hostname each boot


http://i.imgur.com/ysag6A8.png

-Click Save
-Clost Windows

All done!


If you do it like I did, over ssh to a headless raspberry pi...
You can do this to start the script..

mv newhostname /etc/init.d/

update-rc.d newhostname defaults 100

Now reboot your computer...
After that you should see for exemple : user@xRxAebQc

Thanx for me ..

/ztech

ztech
2013-12-05, 07:33
how can I get rid of

insserv: warning: script 'newhostname' missing LSB tags and overrides