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.
I ssh'd to the iPhone, and ran cat /etc/master.passwd, then copied that output to BBEdit (or other text editor). Then I replaced the passwd section (in between the first two colons) with my new hash for both root and mobile users. Finally, I copied the whole thing, swit...