I had been using vncserver and vncviewer combination for several years with Ubuntu and other Linux distros.
If you have any questions or feedback, feel free to leave a comment.
In this tutorial we learned how to install and configure VNC server with two users on Ubuntu 16.04.
Now we need to kill old processes if they are still running and reload the unit files vncserver -kill :2Īnd start using unit files sudo systemctl start systemctl start if you want vnc server on every boot you do one more time same as above just enable instead of start. Then you make another one: sudo nano paste same stuff, just in both cases change user name for your own users. We will actually need to make two for two users lets first create one sudo nano yup put this configuration ĭescription=Start TightVNC server at startupĮxecStartPre=-/usr/bin/vncserver -kill :%i > /dev/null 2>&1ĮxecStart=/usr/bin/vncserver -depth 24 -geometry 1280x800 :%i That is new fancy name of old school startup script. So to avoid that, lets make systemd unit file. This is all good when you manually set the user and the server over SSH, but you have to redo it on every server reboot.
It will think that remote desktop is on localhost and will route the traffic over ssh port to your server, as long as SSH connection is active. With this command you are establishing a SSH tunnel: ssh -L 5902:127.0.0.1:5902 sure to change highlighted part to your IP adress and username.Īfter this you can start Vinagre or Remmina and enter localhot:5902 as your address. Port 22 or any other port that you use for SSH access on a server can be used to trick the VNC viewer that VNC server is running on localhost on port 5901 or 5902. There is solution in that case, we can use SSH tunneling. But what if those ports are closed, by firewall, and it is for some reason impractical to open them. So far we managed to make the connection directly on display ports, in our case 59. Now run vncserver to spwawn the process vncserver :2Īnd you can now connect at port 5902 and have separate session. Then create new one from scratch nano ~/.vnc/xstartupĪnd make it executable: sudo chmod +x ~/.vnc/xstartup First backup the xstartup file mv ~/.vnc/xstartup ~/.vnc/xstartup.backup vncserver -kill :2Īnd we need to actually repeat process from earlier. We need to kill this process in order to be able to edit config file. Other than password, this also crated new process that listens on port 5902.
Lets start first by adding new user sudo adduser newuserĪnd lets make a password for new user vncserver And in turn he will run his own instance of desktop environment, or that could be entirely separate DE. This is done by crating arbitrary number of users and each user will have his own display port and his own instance of VNC server. It is possible to have multiple VNC sessions that don't interfere with each other. If some of users type the view only password (provided that you created one) they would not have control of cursor but they would still be in single session and watch one same screen. You can connect to this session from unlimited number of computers, but then yo would all be controlling one mouse cursor and have same session. Lets first backup this file mv ~/.vnc/xstartup ~/.vnc/xstartup.backupĪnd then create new file from clean slate The file I am talking about is called xstartup and it is found inside hidden. We do this by following command: vncserver -kill :1Īfter this is done, configuration file for VNC server can be edited to select which desktop environment will be started upon connecting to the VNC server. To continue configuration, we actually need to kill all instances of VNC server. If you start multiple instances of VNC you will have multiple display ports, and it will increment both number by 1, to : and so on for every instance. After this process is completed, VNC instance will be launched on port 5901 and VNCserver will count this port as :1. If you don't plan to have spectators you can chose not to enter view only password. This password must be different than your main password. It will also prompt you for view only password, you need that one if you want to have someone connect to your VNC session without control of the cursor and keyboard, only as spectator. Then we need to configure VNC server with password for login on as user 'miki' vncserver Sudo apt install gnome-core xfce4 firefox xfce4-goodies tightvncserver