-- MikeGore - 24 Mar 2020

Linux Remote Desktop Access

8 Sept 2020 Mike Gore
Ubuntu 18.04LTS see RT# 1051887


Linux vpn.cs client setup - VPN required for remote access

  • See https://vpn.cs.uwaterloo.ca for details
    • Download the vpn.cs ovpn file
    • Click on network icon on toolbar
      • Click on VPN -> Connect -> Enter your CS-GENERAL password.

Setting up an Ubuntu 18.04LTS Desktop for remote access

  • You do not want to do this on a server
    • They do not run a GUI.
    • The added packages brought in might mess things up - especially network manager

Linux Ubuntu 18.04LTS Desktop setop for remote access

Desktop software install

  • Install Open VPN client
    • apt-get install gadmin-openvpn-client network-manager-openvpn network-manager-openvpn-gnome
  • Install Tiger VNC server and client
    • apt install tigervnc-standalone-server tigervnc-xorg-extension tigervnc-viewer
  • Install the GUI session manager you will use - I am using Gnome in my examples
    • apt-get install xserver-xorg-core ubuntu-gnome-desktop
  • Desktop related functions
    • apt-get install xdg-desktop-portal xdg-desktop-portal-gtk xdg-user-dirs xdg-user-dirs-gtk xdg-utils
  • Install and RDP server Windows remote desktop and Linux rdesktop clients can access the Desktop
    • apt-get install xrdp
  • Optionally install VPN and RDP client software so you can access other machines
    • apt-get install tigervnc-viewer rdesktop

Desktop Tiger VNC server configuration

  • *Setup a VNC password and make it complex (you can use login password)
    • This restricts who has access to your desktop
    • vncpasswd
      • Enter your login password twice, say NO to a view

Desktop VNC server manual startup script

  • Note on my system I start the server manually
  • Create a startup script called start_vnc
    • chmod 755 start_vnc
    • Update the display geometry below to suit your client display
               #/bin/bash
                              # Kill any existing VNC servers
                              echo We need to stop any VNC servers using sudo - you will be prompted for your password to proceed
                              sudo vncserver -kill :*
                              sudo killall Xtigervnc
                              # Remove any previous stale/dead Xauth files
               xauth remove $HOSTNAME:1
               xauth remove $HOSTNAME:2
               xauth remove $HOSTNAME:3
               xauth remove $HOSTNAME:4
                              # Start vncserver
                              vncserver :1 -localhost -geometry 1800x1000 -depth 24
            

Desktop VNC server client session startup script

  • This step is only done once
  • make sure you have already run vncpasswd from the previous steps
  • The script below will launch your chosen session manager when a client connection is made
    • In my example I use Gnome - I have included other options commented out
  • cd ~/.vnc
  • sudo bash
  • gedit Xvnc-startup
             # Start Gnome 3 Desktop 
             # [ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup
             # Or
             # [ -x /etc/X11/Xvnc-session ] && exec /etc/X11/Xvnc-session 
             # [ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources
             # Or
             /usr/bin/vncconfig -iconic &
             /usr/bin/dbus-launch --exit-with-session /usr/bin/gnome-session &
          
  • chmod 755 xstartup
  • ln -s xstartup Xvnc-startup

XRDP setup for Linux rdeskop and Windows remote desktop access

  • This step is only done once
  • Update xrdp.ini adding restrictions on where XRDP will forward requests to
  • I simplified mine so I will be presented with only one choice with defaults sets
  • We will comment out all [] sections in the later half or the file
    • Create of modify the section [vnc] as follows
    • sodo bash
    • gedit /etc/xrdp/xrdp.ini
               [vnc]
               name=Xvnc
               lib=libvnc.so
               username=na
               password=ask
               ip=127.0.0.1
               port=ask5901
               #xserverbpp=24
               #delay_ms=2000
            
    • Restart xrdp
      • systemctl restart xrdp

Client connection process

  • Make sure your desktop VNC server is running
    • Open a terminal
    • ssh -X userid@host.cs.uwterloo.ca
      • Change userid to yours and host to your desktop
      • Check the xtightvnc server status
        • vncserver -list
      • If you see no sessions listed then start the server
        • ~/start_vnc
  • Important on very first access
    • if you have a session manager already running (ie Gnome) on your desktop you need to kill it
      • Otherwise you will get a connection failure from your clients

Connecting to the Desktop remotely from Linux clients

  • Make sure you have rdesktop installed
    • Example: From a terminal sudo apt-get install rdesktop
  • Starting session
    • open a terminal window and type:
    • rdesktop -r sound:local:alsa -g1850x1000 host.cs.uwaterloo.ca -u userid
        • replace host and userid *with your remote host name and *userid
      • The session will ask for your VNC password you set earlier
        • It will ask you Three times!

Connecting to the Desktop remotely from Windows clients

  • In the search bar type remote desktop
    • Click on the highlighed Remote Desktop app
      • Enter the fully qualified hostname like host.cs.uwaterloo.ca
        • replace host *with your remote host name
      • The session will ask for your VNC password you set earlier
        • It will ask you Three times

Using vnc or rdp with ssh


Then
  • rdesktop localhost::5999

-or-
  • xvncviewer localhost:5999

- or - older systems may have have another viewer like this
  • xvnc4viewer localhost::5999 -ZlibLevel 9 -UseLocalCursor
Edit | Attach | Watch | Print version | History: r13 < r12 < r11 < r10 < r9 | Backlinks | Raw View | WYSIWYG | More topic actions
Topic revision: r13 - 2020-09-11 - MikeGore
 
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2024 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback