How to Change VNC Password using Linux

The VNC is virtual network computing, which allows you to access a remote computer screen via a Remote Frame Buffer protocol (RFB). Though not necessary, it is advisable to set up passwords for VNC servers to prevent any unauthorized access. During the installation of the VNC server, it asks for a password setup. It is a recommended approach to set the VNC password while installing the server. In this guide, I will cover how to change VNC passwords on Linux and how to reset the password if you have forgotten it.

Requirement

System Linux (Any Linux Distribution)
Software Any VNC software such as, RealVNC, TightVNC, TigerVNC, UltraVNC

Note: For the demonstration, I have installed TightVNC on Ubuntu.

How to Change VNC Password on Linux

No matter what VNC server you have installed all the passwords that you set up are stored in ~/.vnc/passwd file.

To change the VNC password in Linux, open the terminal and use the vncpasswd command.

It will ask you to type the password, and upon pressing Enter, it will ask you to verify.

This password will allow the remote user to access your system screen with mouse and keyboard operations.

After that, it will prompt you to enter the view-only password:

The view-only password allows the remote accessor to view the screen without making any interaction using the mouse and keyboard.

The VNC password can also be changed using Standard Input (STDIN):

echo hiVNC | vncpasswd -f > ~/.vnc/passwd

The -f flag will save the password without asking to set the limit.

Note that the above command will only set the primary password, so to set the both primary and view-only passwords use n with -e flag to interpret the escape characters.

echo -e “hiVNCnhiVNC2” | vncpasswd -f ~/.vnc/passwd

The required password length depends upon the installed VNC server, since I have installed TightVNC, the minimum requirement of the password length is 6 characters. If it is equal or shorter than 5 characters the utility will be exited without setting the password. To set a simple password use the -f flag which will silently set the password without warning about the limit.

The same goes for the view-only password, if it is equal or shorter than 5 characters, the utility will only set the primary password, and view-only will not be set.

How to Reset VNC Password if Forgotten

Changing the VNC password is a straightforward method but if you have forgotten the password then you can change it by deleting the ~/.vnc/passwd file and creating it again. Use the following command to delete the VNC password file.

Now, again launch the server:

Launching the server will create the ~/.vnc/passwd file and ask to set the primary and view-only passwords.

Conclusion

VNC is a software utility used to access the remote system screen. There are various VNC server software available on Linux, but passwords of all the servers are saved into ~/.vnc/passwd file. The VNC primary and view-only passwords on Linux can be changed using vncpasswd command and stored in the ~/.vnx/passwd file. The password length should be longer than 5 characters otherwise the password will not be changed.

source

Leave a Comment