DEV Community


Posted on

Remotely access your Linux server’s GUI from your local network

In this post, I’ll describe how to enable remote connections to one’s Linux server’s GUI from other clients on the local network (LAN). If you were instead looking for a way to connect from outside your own LAN, it will most likely involve using some paid VPN service but this post should be useful to you even in that scenario, since you’ll need to first enable remote access on the server for everything else to work.

Which distro?
I am using a recently acquired desktop that I turned into an RHEL server, particularly version 8.5. It goes without saying that this is quite possible with any other Linux distribution, the only difference is the package managers used and location of sharing preferences used to enable desktop sharing. In my experience, I found this same process easiest on Ubuntu.

What will you get at the end?
Ability to work on your server’s desktop from another client just like you would be if you were physically present in front of that server. One possible turnoff would be scaling the resulting image you receive from the server: elongated, too tiny, tiny letters and this usually happens due to difference in resolution between the two devices’ graphics.

For starters:
RHEL 8.5 already comes with the Sharing Preferences dialog (found in Settings) a Remote Viewer (of varied usefulness) and without a need to install vnc server(s).

It’s not as easy as many tutorials describe
Official Red Hat guide describes the whole process very casually: open a menu, switch few things to “on” and you’re done. For one, if you have a combination of Wi-Fi and Ethernet adapters on your server, the dialog that makes it all happen will make available only the Wi-Fi connections. This might throw you off if you have all your clients connecting to the server via an Ethernet LAN. And you may think this is why remote desktop connections don’t work. Disregard this and just switch to “on” at the rolling menu of available networks. Remote desktop access will work even if you turn your client’s Wi-Fi off.
And then, it’s the importance of turning encryption off on the server. Again, a casual mention in the official guide: open the terminal and use a gnome edit command to turn encryption off for remote desktops connections. That won’t help. You’ll need dconf-editor installed and then dig through its menus.

Finally, the steps:
In the Settings menu, open Screen Sharing, turn the slider to on, set up some simple password for the connection, in the list of available networks choose whatever network has a slider by its side and turn that slider to on.
Assume the root powers on your terminal and open the port for remote VNC connections: port 5901
firewall-cmd —-add-port=5901/tcp —-permanent
firewall-cmd —-reload

Also add your Ethernet NIC that connects your server to your LAN to your current firewall zone:
firewall-cmd —-add-interface=enp5s0 —-permanent
firewall-cmd —-reload

Notice how we’re not setting zones to which we’re setting the interface and port as trusted: I’m assuming you already set your server’s firewall zone to “home”- the zone in which all devices on your LAN are trusted.
Lastly, install dconf-editor on the server and then open it, go through org -> desktop->gnome->remote-connections and turn the switch to off.
No need to reset any service nor your server: connections from your clients requesting access to your server’s desktop should work.

Top comments (1)