Remotely access a desktop
Just as you can access a remote console with SSH, you can access a Graphical User Inerface (GUI) with several protocols. In this tutorial I will show you some methods to accomplish this task.
Table of Contents
VNC
Ubuntu
- Install a VNC server, like
tightvncserver
:sudo apt install tightvncserver
- Run the VNC server and add a password.
vncserver :0
- :0 means you want to use display 0, which corresponds to port 5900. You may need to choose another display number if that display is being used. In that case, change
:0
for:1
(which corresponds to port 5901).
- :0 means you want to use display 0, which corresponds to port 5900. You may need to choose another display number if that display is being used. In that case, change
- Kill the server, because we only run it to create vnc config file.
vncserver -kill :0 # change number if applicable
- VNC config file is in
/home/<user>/.vnc/xstartup
. Open the file. - Add at the end of the file the
start
command for your desktop environment:# XFCE startxfce4 & # LXDE startlxde & # GNOME gnome-session &
- In Ubuntu 20.04, using VNC with XFCE will not work as expected (windows will not have title bars).
- Start a new VNC server.
vncserver :1
- Then, you can connect to your server using its IP and port 5900 if you use display :0, 5901 for display :1, etc.
Arch Linux
- Install
tigervnc
.sudo pacman -S tigervnc
- Run
vncpasswd
to create a VNC password. - Edit
/etc/tigervnc/vncserver.users
and add the display number and user you want to use, for example::1=ricardo
- Create a
/home/<user>/.vnc/config
file and add (at least) this.session=<your-desktop-environment>
- You can see your desktop environment name under
/usr/share/xsessions
, for example:session=xfce
- You can specify more settings, like
geometry=1280x720
.
- You can see your desktop environment name under
- Start VNC service, using the display number you want to use.
sudo systemctl start vncserver@:1.service
- Finally, you can access your server using its IP and port 5900 for display :0, 5901 for display :1, etc.
NoVNC
NoVNC is VNC with a web browser. Obviously you need a VNC server before enabling NoVNC.
sudo novnc --listen 80 --vnc 127.0.0.1:5900
Go to http://<server-ip>/vnc.html
and you will access your server.
XRDP
With XRDP you can connect to your server via RDP protocol. Once installed, you can start it by simply typing xrdp
or starting xrdp
service.
Default RDP port is 3389.
If you have any suggestion, feel free to contact me via social media or email.
Latest tutorials and articles:
Featured content: