Separate password for each VNC server


The command vncpasswd allows us to set the VNC password of a VNC session used to access remote desktops. By default the password is saved in $home/.vnc/passwd file.

Generally we create vncserver with the following syntax

vncserver -depth 24 -geometry 1280x768
New 'sun:1 (sam)' desktop is sun:1
Starting applications specified in /home/sam/.vnc/xstartup
Log file is /home/sam/.vnc/sun:1.log

When we try to connect from a remote system to the vnc server, the authentication verified against password in $home/.vnc/passwd file. If we create multiple vnc servers, each session is authenticated is verified with same passwd file.

If we want to set different password for each vncserver created under the same user account, we have to use -rfbauth option while creating vncserver.

We can create a different vnc password by vncpasswd command.
Let us say we want to create another vnc password at the location $home/.vnc/pass1file, then

vncpasswd $home/.vnc/pass1file 
Password:
Verify:

When prompts for the password type it. Retype the password to verify it.

We can create a vncserver which uses this new password for authentication

vncserver -depth 24 -geometry 1280x768 -rfbauth $home/.vnc/pass1file
New 'sun:2 (sam)' desktop is sun:2
Starting applications specified in /home/sam/.vnc/xstartup
Log file is /home/sam/.vnc/sun:2.log

To connect to the sun:1 I use default vnc password. To connect to sun:2 I use the new password.

I general you can create as many vnc servers as you want with different vnc passwords with -rfbauth option in vncserver.

Leave a Comment