First you'll need to install xlock:
sudo apt-get install xlockmoreThen run xlock from a terminal with the following options:
xlock -mode blank -geometry 0x0 -timeout 2
The xlock command locks keyboard and mouse input, the flags do the following:
-mode blank displays a blank box in the top left corner of your monitor.
-geometry 0x0 makes the size of the blank box 0x0 pixels.
-timeout 2 sets the timeout (in seconds) for the password prompt if anyone hits a key.
Update 2011-05-02: A second (better) solution
First you'll need to install xtrlock:
sudo apt-get install xtrlockThen run xtrlock from a terminal:
This will start xtrlock and lock the screen. To unlock the screen type your password and hit enter.