A complete invisibility – anonymity – solution for Ubuntu

Based on some online articles and my previous posts, I created the following script which does the following:

  1. Generates and assigns a random MAC address to my wired card (eth0) and wireless card (wlan0) using the macchanger software described here
  2. Generates and assigns a new hostname to my OS
  3. Applies the new changes in my “/etc/hosts” file
  4. Runs on every startup

IMPORTANT: You MUST have your “127.0.0.1” and “127.0.1.1” entries as the last two lines if you need to run this script EXACTLY as it is. If you don’t want this, you can simply change the “sed” part.

Here is the script:

!/bin/bash

#random_computer_name & random MAC address for both eth0 and wlan0

sudo macchanger -A eth0 #random mac for eth0
sudo macchanger -A wlan0 #random mac for wlan0

sed -i 1,10d /etc/hostname

function randnum
{
number=$[ ( $RANDOM % 15 ) + 8 ]
}

randnum

function randpass
{
newhostname=`
}

randpass

(echo ‘0a’; echo $newhostname; echo ‘.’; echo ‘wq’) | ed -s /etc/hostname

/bin/hostname $newhostname

sed -i ‘$d’ /etc/hosts # deletes the last two lines in /etc/hosts
sed -i ‘$d’ /etc/hosts

echo -e “127.0.0.1    $newhostname localhost\n127.0.1.1    $newhostname” >>/etc/hosts

You can add the above file to your startup following the steps in this link

Appreciate any feedback. Note: I’m already working with this script on my laptop and it’s working fine till now, I just had about 10 seconds idle at the startup screen.

Update: That delay happened only after the first startup and then disappeared

Tagged , , , | Leave a comment

Delete the last line in a text file using sed

sed -i ‘$d’ hobba

-i: to change the file itself, not copy contents to another file or something
$d: delete the last line
hobba: the file name

Tagged , | Leave a comment

Insert a "new line" character in a text file using Bash

echo -e “192.168.100.100\n192.168” >> hobba

 The ‘-e’ option does the magic, as it allows escape characters to be printed

Source

Tagged | Leave a comment

How to delete certain lines of text from a file in Bash using sed

“sed -i 1,+2d file_name”

deletes starting from line ‘1’ and the next ‘2’ lines, i.e. deletes the first 3 lines

Tagged , , | Leave a comment

Cleanup the SSH known_hosts file

ssh-keygen -R [host]

helpful especially in clusters

Tagged , , | Leave a comment