This usually occurs because OpenWindows exited abnormally, leaving the system's keyboard in the wrong mode. The characters that appear when someone attempts to login are garbage transliterations of what someone types.
On a SPARC system: find another machine and remote login to this system, then run this command:
$ /usr/openwin/bin/kbd_mode -a |
On an x86 system: log in remotely and start, then kill the X server, or reboot the system.
The usual reason for this problem occurring is an automated script run from cron(1M) that clears out the /tmp directory every so often. Ensure that any such scripts do not remove the /tmp/.X11-pipe or /tmp/.X11-unix directories, or any files in them.