I have never tried using the passwd command on my jailbroken 1.1.3 iPhone, since everyone warns of its use. However, I don't like having the default root password that everyone in the world knows, so I wanted to figure out a way to change it. It's pretty easy actually. On a Mac or Unix/Linux, the openssl command will do what you need like this:
openssl passwd -crypt -salt /s myNewPasswd
The password can only be eight characters long; anything longer will be truncated. I don't know if the salt has to stay the same or not, but to be safe, I just used the same salt as the original password. I doubt this makes any difference, though.
cat > /etc/master.passwd
I then pasted in the clipboard contents and pressed Command-D. That's it; the password was changed. I ran through most of my apps, put the iPhone to sleep, woke it up, and rebooted all without any problems. You don't need to reboot or do anything else for this to take effect.
Mac OS X Hints
http://hints.macworld.com/article.php?story=20080224231344798