How to enable autologin but still require password

Enable auto login.

Check whether you have installed gnome-screensaver by running following command.

sudo dpkg --get-selections | grep gnome-screensaver

If it is not installed run following command to install gnome-screensaver.

sudo apt-get update && sudo apt-get install gnome-screensaver

Add this command on Startup application.(To open startup application preferences search "Startup applications" on Unity dashboard.

/usr/bin/gnome-screensaver-command -l

enter image description here

This screenshot is a Unity screenshot. But this works on GNOME shell without any modification.

Latest Ubuntu version has a command called loginctl. You can replace startup command with below command and get the same thing done.

loginctl lock-session