Set VNC password

6,354

Solution 1

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

Solution 2

If you want a one-liner, this from https://stackoverflow.com/a/30606811/109707

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

Or if using x11vnc

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

Share:
6,354

Related videos on Youtube

Ryan Newington
Author by

Ryan Newington

Updated on September 17, 2022

Comments

  • Ryan Newington
    Ryan Newington over 1 year

    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?

  • Michael Küller
    Michael Küller almost 12 years
    Ran into the same problem, and this solution helped me. Thanks!