Can anyone say me how to set a VNC password in Ubuntu? Such that if anyone access my machine through VNC it should prompt for a password.

2 Answers 2


You can set a password when you open Remote Desktop.

enter image description here

Or withvncpasswd you can also set the password for the vnc-server.

So if someone want to connect to you, he has to enter the password.

  • vncpasswd doesn't work for me.
    – karthick87
    Apr 24, 2011 at 13:13
  • 2
    Which vnc server do you use? Start Options: vnc4server: Command to start: vncserver. Then run vncpasswd. tightvncserver: Command to start: tightvncserver. Then run vncpasswd. Gnome build in vino-server: Command to start: vino-preferences And Activate: "Allow other users to view your desktop" and set a password.
    – Dani3l
    Apr 25, 2011 at 7:29

In my case, I forgot the password to the VNC server. For my situation, the final target was TightVNC running on Ubuntu 18.04 which I needed to reach from my mac.

You first kill the existing VNC sessions with

vncserver -kill :1

Use something like this to find out if you've killed all sessions. Usually, the vncserver is running on port 5901:

sudo netstat -peanut | grep "vncserver"

If there is something, repeat the kill command with the appropriate vncserver -kill :2 or whatever listing. If nothing, then you can remove the default original password setting with:

sudo rm ~/.vnc/passwd

Restart the vncserver as:


And you'll be prompted again for a new password. The daemon should run on port 5901, which you can query with the netstat command above.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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