Transfer from: http://www.linuxidc.com/Linux/2012-06/62700.htm
Ubuntu 12.04 has a guest user by default, and GUEST users can access the Ubuntu machine without a password.
gksudo gedit /etc/lightdm/lightdm.conf
Add to
allow-guest=false
After modification
[ SeatDefaults]
user-session=ubuntu
greeter-session=unity-greeter
allow-guest=false
Finally restart lightdm
sudo restart lightdm
or
sudo apt-get remove gdm-guest-session