Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I need some help here. Is there a way to set the VNC password without a user interaction? When I run vncpasswd it prompts for a password and then verification of it. I would like to change the password from script. Is this possible?

share|improve this question
up vote 5 down vote accepted

I don't have vncserver, so reading the man page over the web and no way to test....

Have you tried writing the password twice to a temp file and using that as stdin to vncpasswd?

echo $password >/tmp/file
echo $password >>/tmp/file  # note >> for append
vncpasswd </tmp/file >/tmp/vncpasswd.1 2>/tmp/vncpasswd.2

That's for the bash shell. But the basic idea should be obvious. Prompting will wind up in the .1 file and errors in the .2 file

share|improve this answer
Gonna give it a try thanks! – poopa Feb 22 '10 at 7:35
Ran into the same problem, and this solution helped me. Thanks! – Michael Küller May 4 '12 at 9:32

If you want a one-liner, this from

vncpasswd -f <<< $PASSWORD > "$HOME/.vnc/passwd"

Or if using x11vnc

x11vnc -storepasswd $PASSWORD "$HOME/.vnc/passwd"

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.