Tag Archives: linux

Ubuntu – Authentication token manipulation error

Authentication token manipulation error on Ubuntu
Authentication token manipulation error on Ubuntu

Recently, I forgot my “root” password for my Ubuntu (duh!). So I try attempting to change my “root” password by selecting recovery mode on the grub menu and dropped into a root shell prompt.

Everything works perfect until I try to change the password. The picture above is what I get when i try to change the password. 🙁

So, to solve this, just run this on the prompt:

mount -rw -o remount /

Anddddd… Walla! Try to reset the password again and it works! 🙂

Hash sum mismatch error on Ubuntu

I think most of you will encounter with this kind of problem if you are using the previous version of Ubuntu.

W: Failed to fetch gzip:/var/lib/apt/lists/partial/us.archive.ubuntu.com_ubuntu_dists_natty_main_source_Sources  Hash Sum mismatch, 
E: Some index files failed to download. They have been ignored, or old ones used instead.

The solution is to remove the content of /var/lib/apt/lists directory:

sudo rm /var/lib/apt/lists/*

then run:

sudo apt-get update

Credit to askubuntu.com

Disable IPv6 on Ubuntu

If you want to disable IPv6 on your server, below is the step to do it.

  1. Edit this file:
nano /etc/sysctl.conf
  1. Add these lines to the bottom of the file:
net.ipv6.conf.all.disable_ipv6 = 1
net.ipv6.conf.default.disable_ipv6 = 1
net.ipv6.conf.lo.disable_ipv6 = 1
  1. Run this command on your terminal:
sudo sysctl -p

Done!

Enable graphical root login on ubuntu 12.04

In Ubuntu, user “root” won’t show up as an options to login, which you need to adjust the Ubuntu to allow login as “root”.

Run this command below in your terminal (as normal user with sudo):

sudo passwd root
sudo sh -c 'echo "greeter-show-manual-login=true" >> /etc/lightdm/lightdm.conf'

Reboot and then you should be able to login as root using graphical user login.

Restore grub without live CD on Linux

If you start your Ubuntu and it display a grub shell to you, you can run this command below to fix it:

grub-rescue> prompt
             ls
             set prefix=(hdX,Y)/boot/grub
             set root=(hdX,Y)
             set
             ls /boot
             insmod /boot/grub/linux.mod
             linux /vmlinuz root=/dev/sdXY ro
             initrd /initrd.img
             boot

* Ensure that you entered correct partition (e.g. hd0,1) for hdX,Y. If not, than your grub will be messed.

References :
http://superuser.com/questions/181733/how-can-i-restore-grub-without-a-live-cd1
http://www.linux.com/learn/tutorials/776643-how-to-rescue-a-non-booting-grub-2-on-linux

Installing Conpot on Ubuntu 12.04

Conpot is a low interactive server side Industrial Control Systems (ICS) honeypot with the goal to collect intelligence about the motives and methods of adversaries targeting industrial control systems.

For more info, you can refer at here

First, edit your apt list file and insert this line below:

nano /etc/apt/sources.list
deb http://us.archive.ubuntu.com/ubuntu precise main multiverse

After that, update your OS:

sudo apt-get update

Then, install required dependencies:

sudo apt-get install libsmi2ldbl snmp-mibs-downloader python-dev libevent-dev libxslt1-dev libxml2-dev sqlite sqlite3 git

Some of dependencies need to be install via pip:

pip install --upgrade gevent pysnmp lxml bottle jinja2 beautifulsoup4 requests sphinx libtaxii xlrd crc16
  • Ensure that you have installed python-pip before you run this command.

Install Modbus-tk (to create modbus app easily with Python):

cd /opt
git clone https://github.com/glastopf/modbus-tk.git
cd modbus-tk
python setup.py build
python setup.py install

Install Conpot:

cd /opt
git clone https://github.com/glastopf/conpot.git
cd conpot
python setup.py build
python setup.py install

Finish! Next step is to run the conpot:

$ conpot

Conpot is running on these port:

$ netstat -lnput | grep python
tcp 0 0 0.0.0.0:102 0.0.0.0:* LISTEN 62822/python
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 62822/python
tcp 0 0 0.0.0.0:502 0.0.0.0:* LISTEN 62822/python
udp 0 0 0.0.0.0:161 0.0.0.0:* 62822/python

Do ensure that those port is not occupied or used yet.

Installing Comodo Positive SSL Certs on Apache

Recently, I purchased Comodo Positive SSL for one of my web. Since this is my new experience on installing SSL onto Apache, I write this article so that anyone can refer to this step and also as my personal note.

  1. Before you install the certificates, you need to set up your virtual hosts and Apache configuration.
    In /etc/apache2/ports.conf add this line:
NameVirtualHost *:443

So the ports.conf will be something like this:

NameVirtualHost *:80
Listen 80

NameVirtualHost *:443
  1. Then in your vhost file which is usually located at /etc/apache2/sites-enabled/default-ssl, edit or make sure this line is there:
<VirtualHost _default_:443>

SSLEngine on
SSLCertificateFile    /etc/ssl/crt/www_your_domainname_org.crt
SSLCertificateKeyFile /etc/ssl/crt/private.key
SSLCACertificatePath /etc/ssl/crt/
SSLCACertificateFile /etc/ssl/crt/www_your_domainname_org.cer

SSLCertificateFile
This is the actual SSL certificate. Comodo will name it after your domain e.g. www_your_domainname_org.crt. So just copy the file into the correct directory /etc/ssl/crt/ and make sure your vhost file points to it.

SSLCertificateKeyFile
When you first generated your CSR to send to the commercial SSL issuer you should have gotten a key file. You just need to move it into the same folder as your SSL cert if it’s not there already and point the line to your vhost config.

SSLCACertificateFile
Comodo sends you that zip file with 3 individual CRT files in it you need to combine a couple of them into one file. You can ignore the file named after your domain and just focus on the other two. You need to combine them into one file in a very specific order.

Run this command to generate a file that matches your vhost config, remembering to change the file names to whatever the SSL issuer has given you:

cat PositiveSSLCA2.crt AddTrustExternalCARoot.crt > www_your_domainname_org.cer

Then, restart your server:

sudo a2enmod ssl
sudo service apache2 restart

MongoDB on Raspberry Pi

Recently, I want to install MongoDB in my Rasp Pi. But unfortunately, I can’t install MongoDB via apt-get because Rasp Pi is using ARM architecture.

Maybe we can compile it from source code. Yes. We can. But MongoDB source is very x86 specific, meaning the newest version isn’t available for ARM architecture.

But… Thanks to this owsem patches from Per Ola Ingvarsson on Github at https://github.com/skrabban/mongo-nonx86, now we can compile MongoDB on Rasp Pi. Yeay!

So, to build MongoDB on your RaspberryPi:
Install the required packages:

sudo apt-get install git-core build-essential scons libpcre++-dev xulrunner-dev libboost-dev libboost-program-options-dev libboost-thread-dev libboost-filesystem-dev

Clone the Github repo:

git clone https://github.com/skrabban/mongo-nonx86

Now let’s compile it! (*Note that these two steps take a very very long time on a Rasp Pi. So I left mine for 1 day for this.)

cd mongo-nonx86
scons
sudo scons --prefix=/opt/mongo install

Done! You have MongoDB installed on your Rasp Pi.

This will install mongo in /opt/mongo, to get other programs to see it, you can add this dir to your $PATH:

PATH=$PATH:/opt/mongo/bin/
export PATH

Update MySQL root password

To change your MySQL root password, first you need to connect to the sql server via terminal
mysql -u root -p

In my case, my root password is null/empty. So I need to create new mysql root password.
So, after you login to the mysql, enter this command:

use mysql;
update user set password=PASSWORD("") where User='root';
flush privileges;