Back in 2008 and 2009, I've already introduced (see THIS and THIS) MobileTerminal (by Allen Porter), a local, Cydia-based (sorry, jailbreak is required!) terminal emulator you can use for a lot of things; among other things, changing the root password from the default „alpine” to something (if you do install OpenSSH) less dangerous.
At MacRumors, forum users have asked the current, iOS 4.x – 5.x-compliant reincarnations of these apps. I've found the „official” Cydia repositories only keep the severely outdated and, now, under new iOS versions, useless version 364.1-10 of MobileTerminal. A screenshot:
(The red oval shows the [old] version number and the warning of it not being compatible with newer OS'es)
To gain access to the (currently) latest one, 520-1, you must add either yourcydiarepo.org or cydia.xsellize.com as a Cydia source. The MobileTerminal version in these repositories is fully compatible with new iOS versions. The right version:
(note the new version, annotated with a red oval!)
Note that in the new version gestures are disabled by default, as opposed to the old version, where there were VERY useful. You will definitely want to enable them; e.g., up-swipe for the „Up” key to repeat the previous command etc.
Side note: programmatically changing the root password
For my article on enhancing the video shooting capabilities of the iPhone 4 (backup article HERE, should iPhone Life encounter connection problems), I've made some extensive research on how it can be changed programmatically (e.g., with a single system() call from Objective-C, as is done with changing system plist permission in the app delegate of my code). It seems it's impossible. The only viable option would be using Perl's crypt() (see THIS), but Perl isn't pre-installed on iOS. You can't use mkpasswd (see THIS and THIS) either (it's non-existing, which isn't surprising, given that, basically, it's just a front-end for the Perl crypt()).
All in all, it seems there's no way of changing the root password without forcing the user to install a terminal emulator on his iDevice (or the OpenSSH + Putty combo on his iDevice and desktop, respectively) and manually change the password.