Put this little script into you ~/.bashrc and you can run it from anywhere:
genpasswd() { local l=$1 [ "$l" == "" ] && l=20 tr -dc A-Za-z0-9_ < /dev/urandom | head -c ${l} | xargs }
It takes one parameter which says how long a password you want:
tdd@s10e-tdd:~$ genpasswd 10 EpVrnblbz_ tdd@s10e-tdd:~$
Source: http://www.cyberciti.biz/tips/linux-unix-bsd-openssh-server-best-practices.html