1

Any recommendations on how I can connect from Windows 10, to Ubuntu 19.04 over home wifi (but preferably from anywhere on the internet), and do a screenshare of Ubuntu desktop, and control the desktop from Windows?

I tried using Chrome Remote Desktop, which sounded like an amazingly easy solution, except that CRD did not load the sudo user/created a new desktop environment, and following directions from here simply made my Ubuntu computer unusable.

I also tried the windows Remote desktop connection, which did roughly the same thing as above (with a weird interface).

Any help would be much appreciated!

1 Answer 1

0

The couple of times I tried to use RDP to access my Ubuntu machines from Windows it didn't work (my personal experience) so I decided to use VNC.

I used these instructions to setup VNC Server on my Ubuntu machines and then access the machine using a VNC Client from windows with SSH.

To start, run the command sudo apt install tightvncserver on the Ubuntu machine

Once you have VNC installed you will need to specify a password to protect access to the VNC server. To do this run:

vncpasswd

and enter a suitable password.

Starting and Stopping the VNC Server

The next thing you need to learn how to do is start and stop the VNC server. Start the VNC Server with the following command:

vncserver

Assuming no problems are encountered vncserver will output a message that looks something like:

New 'myhost:1 (src)' desktop is myhost:1

Creating default startup script /home/neil/.vnc/xstartup
Starting applications specified in /home/neil/.vnc/xstartup
Log file is /home/neil/.vnc/myhost:1.log

The key information here is that vncserver has started up an X server as display :1 on system "myhost" and that it has created a sub-directory called .vnc in the home directory of the user that started the server containing a startup script called xstartup. In addition it has also created a log file that can be reviewed to diagnose any problems should the server have failed to start.

To stop the VNC server simpy run the following command:

vncserver -kill :1

where the :1 matches the display that was indicated when vncsever started up. This will display something along the lines of:

Killing Xvnc process ID 15609

A useful point to note here is that process being killed in called Xvnc. Xvnc is the the actual VNC server process. The vncserver command we ran to launch the VNC server is actually a shell script that sets up the environment prior to launching the Xvnc process.

Configuring the Desktop Environment to be Launched by VNC

The next step is to configure what gets started up when the VNC server is launched. As outlined previously the first time a user starts vncserver the .vnc directory is created in their home directory. Change directory to $HOME/.vnc and load the xstartup file into an editor. It should appear as follows:

#!/bin/sh

# Uncomment the following two lines for normal desktop:
# unset SESSION_MANAGER
# exec /etc/X11/xinit/xinitrc

[ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup [ -r
$HOME/.Xresources ] && xrdb $HOME/.Xresources xsetroot -solid grey
vncconfig -iconic & xterm -geometry 80x24+10+10 -ls -title
"$VNCDESKTOP Desktop" & twm &

These commands perform some basic tasks such as setting the background of the X window, launching an X terminal window and finally launching the twm window manager. The twm window manager is a very good lightweight window manager. Another good lightweight manager is the Motif Window Manager (mwm). Those familiar with the Common Desktop Environment (CDE) on Solaris, HP and IBM systems may want to change to the "twm &" to "mwm &" in the xstartup script.

Another option is to launch the GNOME or KDE desktop environments. To launch the GNOME desktop environment change the twm line in xstartup to:

gnome-session &

Similarly to launch the KDE desptop environment change the line to:

startkde &

Feel free to add other commands to the xstartup script. For example if you would like your favorite mail tool or development IDE to launch automatically then xstartup is the place to do it.

Installing the VNC Viewer Client

Having selected the desktop environment you would like to use the next step is to install the client side VNC viewer. On Linux and Unix systems the viewer is called vncviewer. Check to see if you already have VNC installed on the client system. If it is not already installed or you are running on Windows we once again recommend that you download TightVNC from the site.

Establishing a Secure Shell connection between the two systems

For security reasons it is recommended that the VNC communication take place through an encrypted secure tunnel connection. On Linux or Unix this can be achieved using the ssh command. On Windows we recommend that you use PuTTY which is freely available from putty.nl

By default the VNC server will communicate on port 59xx where xx represents the display number. If vncserver announces that it is running as display :1 then the port being used is 5901. If it tells you it is display :2 then port 5902 is being used and so on.

Supposing you have the VNC running on display :1 on a system called myhost then you would need to establish an ssh connection as follows:

Linux:

ssh -L 5901:localhost:5901 myhost

Windows using PuTTY:

  1. Start PuTTY, enter the hostname or IP address of the system running VNC server. In our example this is "myhost"

  2. Set the "SSH" toggle.

  3. Select the "Tunnels" option from beneath SSH in the "Category" list and enter the following information:

    Source port: 5901 Destination: myhost:5901
    
  4. Save the profile you have entered by selecting "Session" from the Category list, entering name in the "Saved Sessions" text field and press "Save"

  5. Press the "Open" button to establish the secure connection.

In both the case of Linux and Windows you will be prompted for a password for the user under which you are logging in.

Launching the VNC Viewer Client

Assuming all went smoothly with the VNC server installation and that you have established a secure shell connection using the appropriate port (in our example 5901) you can now launch the VNC viewer client. On Linux or UNIX this is done as follows:

vncviewer localhost:1

On Window using TightVNC simply launch the TightVNC viewer and enter localhost:1 into the Connection details dialog and press "OK".

In both cases you will prompted for a password. This is the password that you specified when you ran vncpasswd earlier. After short delay you should see a large window appear dispalaying your Linux desktop and you can work with it as if you were sitting in front of your console.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .