If your iPhone was recently "Rickrolled" by a worm that targets jailbroken iPhones, the following six steps will show you how to change the root password--used to connect to your device via a Unix software secure shell--to protect yourself in the future.
Before starting, you will need to have MobileTerminal installed from the Cydia store. Then:
1. Tap the MobileTerminal icon to open a terminal window.
2. Enter su and press return.
3. Enter the current default root user password alpine and press return.
4. Type passwd and press return.
5. Enter a new password and press return.
6. Enter the new password again and press return.
Updated 11/11/09 at 5:27 p.m. PST: One commenter pointed out that the mobile user account, the default user on the iPhone, can access all your data and shares the same default password of alpine. You can change the mobile password by launching MobileTerminal and following steps 4 through 6 above.