Setting the root password in preseed.cfg for unattended installation

Mar 31, 2010  

Following my previous post about automatic installations of ubuntu karmic, here is a quick tips to set the root password automatically.
Edit your preseed.cfg
The unsafe solution:

# Root password, either in clear text
d-i passwd/root-password password r00tme
d-i passwd/root-password-again password r00tme

The safe solution:
You need the mkpasswd util from the whois package

apt-get install whois

Then you can generate you secure password and put the returned value in your preseed.cfg.

# printf "r00tme" | mkpasswd -s -m md5
$1$CHp7HkQW$Z2ZTY5cZMurbwbqU1zaS.1
# or encrypted using an MD5 hash.
d-i passwd/root-password-crypted password $1$CHp7HkQW$Z2ZTY5cZMurbwbqU1zaS.1