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
You can set a password when you open Remote Desktop.

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.
- 359
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:
vncserver
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.
- 171