📜 ⬆️ ⬇️

Ubuntu + XRDP + x11RDP terminal server, with sound support, for surfing the Internet - a step by step guide

Especially impatient I send immediately to the end of the article where there will be a link to the finished .deb-package for installation.

And for everyone else ...

What is it and what is it for?


First of all, this solution can be used as a very budget option for implementing secure access to the Internet for employees of a small company.
')

Story number one. (based on real events)


Suppose the accountant, at the end of the reporting period, when everything is on the ears, on
E-mail comes a terrible letter from the "Tax Police" in which it says that her company has come under a terrible check and she should immediately read the official document in the file attached to the letter.
In a panic, the accountant is trying to open the attached file and ... all the computers of the company that are currently connected to the internal local network receive a portion of the virus clerk that paralyzes the work of the company for more than one day.

In the case of the implementation of access through the terminal at all! computers blocked direct access to the Internet. If an employee needs to surf the net (mail, skype, messenger), then he simply clicks on the icon on the desktop and goes to an alternative desktop where he can do anything. In the case of infection when viewing mail or in any other way, the virus gets on a single local machine (terminal session) that does not have access to the enterprise network and other computers. Also in this session are not stored important documents and accounting databases. Therefore, there will be absolutely no damage, even with the complete removal of information within the session. Also, the terminal session can be simply minimized to the tray and opened as needed, if a message from the messenger peeps or a Skype call arrives.

Story number two. (based on real events)


Suppose one of the employees brought a hacked licensed program on a flash drive that you put on your computer, in this case we don’t consider AD domain structures, we are talking about small companies that do not have a network of network salesmen. After installing this program, she can calmly complain to the developers via the Internet that someone has installed the hacked version on the computer for this IP and calmly uses it.
Next thing technology. Moreover, the disassembly can be very serious.
When implementing the server terminal option, this option also does not work as the local computer simply does not have access to the network and any spy program cannot remove the dirty material from the hut.

Foreword


This guide is primarily aimed at novice system administrators who want to understand the essence of the issue. So for advanced in the text can be a lot of excess. In the guide I will try to describe in detail the process of setting up a linux terminal server used for safe Internet surfing and describe the solution to known problems.

In order for everything to pass successfully, I strongly advise, for a start, to use the same software versions as in this description. Then, based on the experience gained, you can implement this project on the equipment and software that is convenient for you.

The assembly and testing was carried out on a virtual machine from virtualbox. When using pure iron, there may also be problems with driver settings. From the software, Ubuntu 16.04 LTS server / x11RDP 7.6 / xRPD 0.9.2 was used. On other versions, this solution was not tested or tested.

XRDP


XRDP is a special proxy server that listens on RDP port 3389 for external requests. Accepts connections to it and further, depending on the settings, forwards them to the internal ports of the OS.

To install we compile the necessary packages:

sudo apt install -y git autoconf libtool pkg-config libxrandr-dev nasm libssl-dev libpam0g-dev \ libxfixes-dev libx11-dev libxfixes-dev libssl-dev libxrandr-dev libjpeg-dev flex \ bison libxml2-dev intltool xsltproc xutils-dev python-libxml2 xutils libpulse-dev make libfuse-dev 

By default, the UBUNTU 16.04 repositories contain the xRDP v0.6.0 package in which I could not find a solution for the sound transmission. Therefore, we will build a new version of xRDP from source.

Many sites advise you to clone the latest version with git:
git clone git: //github.com/FreeRDP/xrdp.git

But, in this case, there is a risk that, at the time of testing, you may encounter a completely new version that has significant differences from v0.9.2 and something may go wrong. Therefore, download and unpack the fixed XRDP v0.9.2 package from the developers site.

 cd~ wget https://github.com/neutrinolabs/xrdp/archive/v0.9.2.zip unzip v0.9.2 mv xrdp-0.9.2 xrdp 

Go to the directory with XRPD and start compiling:

 cd ~/xrdp ./bootstrap 

At this stage it is necessary to indicate to the compiler that it is necessary to add a sound support module to the finished assembly. You can read more about this in the file that is now on your disk in the XRDP source directory.

cat ~ / xrdp / sesman / chansrv / pulse / pulse-notes.ubuntu.txt

Install the libraries necessary for audio redirection.

 sudo apt-get install -y libjson0-dev libsndfile1-dev 

Add the key activating sound --enable-load_pulse_modules during the configuration of the package, assemble and install.

 ./configure --enable-load_pulse_modules --enable-jpeg --enable-fuse --disable-ipv6 make sudo make install 

Now copy the security key. This file contains an RSA key pair used to authenticate a remote client. The public key is self-signed. If you do not do this, then we get an RDP error when connecting.

 sudo mkdir /usr/share/doc/xrdp sudo cp /etc/xrdp/rsakeys.ini /usr/share/doc/xrdp/rsakeys.ini 

We add XRDP to autoload. For autoloading we will use systemd:

 sudo sed -i.bak 's/EnvironmentFile/#EnvironmentFile/g' /lib/systemd/system/xrdp.service sudo sed -i.bak 's/sbin\/xrdp/local\/sbin\/xrdp/g' /lib/systemd/system/xrdp.service sudo sed -i.bak 's/EnvironmentFile/#EnvironmentFile/g' /lib/systemd/system/xrdp-sesman.service sudo sed -i.bak 's/sbin\/xrdp/local\/sbin\/xrdp/g' /lib/systemd/system/xrdp-sesman.service sudo systemctl daemon-reload sudo systemctl enable xrdp.service 

Reboot.

 sudo reboot 

Check if the installation passed:

 xrdp -v 

$ xrdp: A Remote Desktop Protocol server.
Copyright © Jay Sorg 2004-2014
See www.xrdp.org for more information.
Version 0.9.2

If everything is done correctly, now you can try to connect to the server using any RDP client from another computer. Or install the freerdp client on the same test machine:

 sudo apt install -y freerdp-x11 

And connect locally within the system.

 xfreerdp /v:127.0.0.1 

It will not go further than the start screen because we have not yet installed the server part of the software of which the XRDP proxy server would have to transfer control.

x11RDP


As the server side, server modules supporting different data transfer protocols can be used. In this embodiment, we will use x11RDP v7.6.

Small retreat


The thing is that the XRDP 0.9.2 proxy we installed earlier cannot, without any modifications, transfer connections to the previous version of the x11RDP v7.1 server, which, in turn, lacks the known problem with switching ru / en keyboard layouts A new session and when reconnecting to the old session.

And when using the old version of the proxy XRDP 0.6.0 with which the x11RDP v7.1 server is working, we will not be able to transfer the sound since XRDP 0.6.0 does not support the --enable-load_pulse_modules key.

To install x11RDP v 7.6 we return to the directory:

 cd ~/xrdp/xorg/X11R7.6 

Create a directory to install the package and make the assembly.

 sudo mkdir /opt/X11rdp time sudo ./buildx.sh /opt/X11rdp 

The assembly takes quite a long time 15-30 minutes. The time command will allow us to see, at the end of the process process, how much time was spent.

Create the symlinks:

 sudo ln -s /opt/X11rdp/bin/X11rdp /usr/local/bin/X11rdp sudo ln -s /usr/share/fonts/X11 /opt/X11rdp/lib/X11/fonts 

Now we have both RDP proxy and RDP server to which the proxy will transfer control. But there is no graphical application that the RDP server can display.

For further testing, to make sure that all the settings were successful, install the xterm graphical terminal emulator.

 sudo apt -y install xterm 

And try to connect to the server from the side, or locally if you have previously installed freerdp.

 xfreerdp /v:127.0.0.1 

Now, from the menu, you need to select x11RDP to specify the proxy to which server should be transferred control and enter the username and password to the ubuntu server.

If everything is correct, then on the screen we will see the graphic interface of the xterm terminal.

Setting the language console and language switching mode


Almost all the basic keyboard settings in ubuntu are made using the setxkbmap package.

To begin, close the terminal session and return to the console of our ubuntu server
let's see what's going on with the keyboard.

 setxkbmap -print –verbose 

$ keycodes: xfree86 + aliases (qwerty)
types: complete
compat: complete
symbols: pc + us + ru: 2 + group (alt_shift_toggle)
geometry: pc (pc104)
xkb_keymap {
xkb_keycodes {include "xfree86 + aliases (qwerty)"};
xkb_types {include “complete”};
xkb_compat {include “complete”};
xkb_symbols {include "pc + us + ru: 2 + group (alt_shift_toggle)"};
xkb_geometry {include "pc (pc104)"};
};

Now connect to the terminal server and execute the same command in the xterm terminal:

 setxkbmap -print –verbose 

$ Trying to build keymap using the following components:
keycodes: xfree86 + aliases (qwerty)
types: complete
compat: complete
symbols: pc + us + inet (pc105)
geometry: pc (pc105)
xkb_keymap {
xkb_keycodes {include "xfree86 + aliases (qwerty)"};
xkb_types {include “complete”};
xkb_compat {include “complete”};
xkb_symbols {include "pc + us + inet (pc105)"};
xkb_geometry {include "pc (pc105)"};
};

Pay attention to the inconsistency in the testimony. On our ubuntu server, everything is fine:
symbols: pc + us + ru: 2 + group (alt_shift_toggle)

There is a Russian console and the alt_shift language switch keys are defined. On the terminal server, the opposite is:

symbols: pc + us + inet (pc105)

There is only English and the language keys are not defined.

There is another oddity. Locally, on the ubuntu server, the keyboard model is defined as pc104:

geometry: pc (pc104)

And on the terminal server as pc105:

geometry: pc (pc105)

If you decide to test not on a virtual machine, but on pure hardware
This result may vary depending on the type of equipment used.

Let's go back to the ubuntu server and see what is installed in the system configuration files.
default

 cat /etc/default/keyboard 

$ # KEYBOARD CONFIGURATION FILE
# Consult the keyboard (5) manual page.
XKBMODEL = "pc105"
XKBLAYOUT = "us, ru"
XKBVARIANT = ","
XKBOPTIONS = "grp: alt_shift_toggle, grp_led: scroll"
BACKSPACE = "guess"

Install hwinfo (system hardware information collector) and look at information about hardware:

 sudo apt install -y hwinfo sudo hwinfo | grep XkbModel 

$ XkbModel: pc104

As a result, the hardware model of the keyboard, in our case, is defined as pc104, in the system configuration files is written appeal to the pc105 device. On a local server, pc104 is defined, on a terminal server pc105. Because of this discrepancy, in particular, there are several glitches. Many people write that they can not cope with setting up a locale on a terminal server. For some, Russification disappears after reconnecting to the fallen-out session and those ne.

Open in any text editor (I use the nano editor in the example) system configuration file and correct the default keyboard type according to the data from hwinfo:

 sudo nano /etc/default/keyboard 

XKBMODEL = "pc104"

The XRDP 0.9.2 program keyboard settings file is in the file
/etc/xrdp/xrdp_keyboard.ini. The proxy sends this data to the xRDP server as the data of the client that makes the connection. Open it and add a block of Russian locale support to the end of this file.

→ Source

Having previously corrected the keyboard model to the correct model = pc104 (the pc105 is installed in the original version):

 sudo nano /etc/xrdp/xrdp_keyboard.ini 

Add to the end of the file:

[rdp_keyboard_ru]
keyboard_type = 4
keyboard_subtype = 1
model = pc104
options = grp: alt_shift_toggle
rdp_layouts = default_rdp_layouts
layouts_map = layouts_map

[layouts_map]
rdp_layout_us = us, ru
rdp_layout_en = us, ru

Reboot.

Connect to the terminal server. Check the keyboard settings:

 setxkbmap -print -verbose 

$ Trying to build keymap using the following components:
keycodes: xfree86 + aliases (qwerty)
types: complete
compat: complete
symbols: pc + us + ru: 2 + group (alt_shift_toggle)
geometry: pc (pc104)
xkb_keymap {
xkb_keycodes {include "xfree86 + aliases (qwerty)"};
xkb_types {include “complete”};
xkb_compat {include “complete”};
xkb_symbols {include "pc + us + ru: 2 + group (alt_shift_toggle)"};
xkb_geometry {include "pc (pc104)"};

Everything is in order, the keyboard is determined correctly:

geometry: pc (pc104)

and there was a Russian language with switching on alt_shift. We close the session leaving it to work in the background and reconnect to it again to check that there is no known problem in which the locale disappears when reconnecting to an already open session.

SOUND


In ubuntu older than 10.10, by default, the pulseaudio server is responsible for audio output. It is already installed in desktop distributions. In the server is not. Therefore, install it.

 sudo apt install -y pulseaudio 

Let's see and write down the version number of the package that is installed by default on our system:

 pulseaudio –version 

$ pulseaudio 8.0

Now we need to build libraries for sound redirection. Details about this are written in the XRDP source file which we have previously viewed when building the XRDP.
cat ~ / xrdp / sesman / chansrv / pulse / pulse-notes.ubuntu.txt

To get started, download the sources of pulseaudio. This can be done in two ways.

1. Download the general version from the developers site ( freedesktop.org/software/pulseaudio/releases/ ) you need to download exactly the version that we identified earlier. In our case, pulseaudio 8.0

2. More correctly - connect the deb-src repositories of the system and get the source code used by the authors of this ubuntu distribution.

By default, links to sources in ubuntu are disabled. To connect, edit the repository list file:

 sudo nano /etc/apt/sources.list 

It is necessary to remove the # icons in front of all the lists of deb-src repositories.

It was:
deb ru.archive.ubuntu.com/ubuntu xenial universe
# deb-src ru.archive.ubuntu.com/ubuntu xenial universe
deb ru.archive.ubuntu.com/ubuntu xenial-updates universe
# deb-src archive.ubuntu.com/ubuntu xenial-updates universe

It became:
deb ru.archive.ubuntu.com/ubuntu xenial universe
deb-src archive.ubuntu.com/ubuntu xenial universe
deb ru.archive.ubuntu.com/ubuntu xenial-updates universe
deb-src archive.ubuntu.com/ubuntu xenial-updates universe

Otherwise, we get an error:
$ E: You must fill in sources.list by placing the package sources URI

Download the source:

 cd ~ sudo apt update apt-get source pulseaudio sudo apt-get build-dep pulseaudio cd ~/pulse* time dpkg-buildpackage -rfakeroot -uc -b 

Go to the XRDP installation directory:

 cd ~/xrdp/sesman/chansrv/pulse/ 

Fix the make file.

 sudo nano Makefile 

In the line:

PULSE_DIR = /home/lk/pulseaudio-1.1

We are changing the path to our catalog with pulseaudio libraries. In this case, please note that constructions like ~ / pulseaudio * in this case do not work. You must accurately register the address of the directory.
PULSE_DIR = / home / admin /pulseaudio-8.0

Replace admin with the username on your system. Save the corrected file and do:

 sudo make 

If everything is done correctly in the directory 2 new libraries will be compiled
module-xrdp-sink.so and module-xrdp-source.so .

It remains only to copy them into the working directory with the pulseaudio server libraries:

 sudo chmod 644 *.so sudo cp *.so /usr/lib/pulse*/modules 

After restarting the sound will be activated.

It remains to install any convenient graphical shell. For a terminal server, it is desirable that something is not resource-intensive.

Xfce
The minimum set of items:

 sudo apt-get install xfce4 

Full set of items:

 sudo apt-get install xubuntu-desktop 

Lxde
The minimum set of items:

 sudo apt-get install lxde-core 

Full set of items:

 sudo apt-get install lxde 

Depending on the version of the installed GUI, you may need to configure the .xsession file to launch it.

For LXDE

 echo lxsession > ~/.xsession 


For XFCE

 echo xfce4-session > ~/.xsession 

Ready package for installation


github.com/suminona/xrdp-ru-audio
in which included:

XRDP v0.9.2 + compiled libraries pulseaudio 8.0 + fixed keyboard.ini file to support Russification. Those who do not want to build the x11RDP v7.6 backend themselves can download the ready deb package of the xorg v.0.2.0 backend from the same link. Installation procedure for completely lazy

 sudo apt-get -y install pulseaudio sudo dpkg -i xrdp-v0.9.2-rus-audio.deb sudo dpkg -i xorgxrdp-0.2.0.deb sudo apt install -y xfce4 chromium-browser sudo reboot 

I repeat that the packages were collected almost on my knees and the work was tested only
on ubuntu 16.04 server. The performance of these .deb packages on other systems is not guaranteed.

Source: https://habr.com/ru/post/329066/


All Articles