Linuxにアクセスするとき、通常はCLIで事足りるのでsshdの設定だけでよいのだが、いろいろとインストールするのに、GUIを使いたかった。Ubuntu(18.04 LTS)のデスクトップにリモートアクセスするときに、いろいろと調べていたら、xrdpを使えば、Windowsのリモートデスクトップクライアント(mstsc.exe)でアクセスできるとのこと。
そんなわけで、xrdpをインストールして、設定してみた。
xrdpをインストール
~$ sudo apt install xrdp
次に、xrdpの設定を変更。「new_cursors」の設定を無効化する。そして、サービスを再起動。
~$ sudo sed -e 's/^new_cursors=true/new_cursors=false/g' -i /etc/xrdp/xrdp.ini
~$ sudo systemctl restart xrdp
「.xsessionrc」を作成する。これは、参考にしたページで紹介されていたものをまるっと流用。
~$ D=/usr/share/ubuntu:/usr/local/share:/usr/share:/var/lib/snapd/desktop
~$ cat < ~/.xsessionrc
> export GNOME_SHELL_SESSION_MODE=ubuntu
> export XDG_CURRENT_DESKTOP=ubuntu:GNOME
> export XDG_DATA_DIRS=${D}
> export XDG_CONFIG_DIRS=/etc/xdg/xdg-ubuntu:/etc/xdg
> EOF
Authentication Requiredの回避設定を行う。これをやらないとダメだった(先人は偉大)。 「/etc/polkit-1/localauthority/50-local.d/xrdp-color-manager.pkla」の設定を変更する。
~$ sudo cat /etc/polkit-1/localauthority/50-local.d/xrdp-color-manager.pkla
[Netowrkmanager]
Identity=unix-user:*
Action=org.freedesktop.color-manager.create-device
ResultAny=no
ResultInactive=no
ResultActive=yes
polkitのサービスを再起動する。
sudo systemctl restart polkit
Windowsからリモートデスクトップクライアントで接続する。
参考: https://www.hiroom2.com/2018/04/28/ubuntu-1804-xrdp-gnome-ja/
インストールしたときのログ
zen@ubClient:~$
zen@ubClient:~$ apt search xrdp
ソート中... 完了
全文検索... 完了
xorgxrdp/bionic 0.9.5-2 amd64
Remote Desktop Protocol (RDP) modules for X.org
xrdp/bionic 0.9.5-2 amd64
Remote Desktop Protocol (RDP) server
xrdp-pulseaudio-installer/bionic 0.9.5-2 amd64
Remote Desktop Protocol (RDP) server - PulseAudio module installer
zen@ubClient:~$
zen@ubClient:~$
zen@ubClient:~$
zen@ubClient:~$
zen@ubClient:~$
zen@ubClient:~$ sudo apt install xrdp
[sudo] zen のパスワード:
パッケージリストを読み込んでいます... 完了
依存関係ツリーを作成しています
状態情報を読み取っています... 完了
以下の追加パッケージがインストールされます:
xorgxrdp
提案パッケージ:
guacamole xrdp-pulseaudio-installer
以下のパッケージが新たにインストールされます:
xorgxrdp xrdp
アップグレード: 0 個、新規インストール: 2 個、削除: 0 個、保留: 0 個。
498 kB のアーカイブを取得する必要があります。
この操作後に追加で 3,303 kB のディスク容量が消費されます。
続行しますか? [Y/n] Y
取得:1 http://jp.archive.ubuntu.com/ubuntu bionic/universe amd64 xorgxrdp amd64 0.9.5-2 [78.7 kB]
取得:2 http://jp.archive.ubuntu.com/ubuntu bionic/universe amd64 xrdp amd64 0.9.5-2 [419 kB]
498 kB を 0秒 で取得しました (3,298 kB/s)
以前に未選択のパッケージ xorgxrdp を選択しています。
(データベースを読み込んでいます ... 現在 170920 個のファイルとディレクトリがインストールされています。)
.../xorgxrdp_0.9.5-2_amd64.deb を展開する準備をしています ...
xorgxrdp (0.9.5-2) を展開しています...
以前に未選択のパッケージ xrdp を選択しています。
.../xrdp_0.9.5-2_amd64.deb を展開する準備をしています ...
xrdp (0.9.5-2) を展開しています...
ureadahead (0.100.0-20) のトリガを処理しています ...
libc-bin (2.27-3ubuntu1) のトリガを処理しています ...
xrdp (0.9.5-2) を設定しています ...
Generating 2048 bit rsa key...
ssl_gen_key_xrdp1 ok
saving to /etc/xrdp/rsakeys.ini
Created symlink /etc/systemd/system/multi-user.target.wants/xrdp-sesman.service → /lib/systemd/system/xrdp-sesman.service.
Created symlink /etc/systemd/system/multi-user.target.wants/xrdp.service → /lib/systemd/system/xrdp.service.
systemd (237-3ubuntu10.11) のトリガを処理しています ...
man-db (2.8.3-2ubuntu0.1) のトリガを処理しています ...
xorgxrdp (0.9.5-2) を設定しています ...
libc-bin (2.27-3ubuntu1) のトリガを処理しています ...
ureadahead (0.100.0-20) のトリガを処理しています ...
zen@ubClient:~$
zen@ubClient:~$ cat /etc/xrdp/xrdp.ini | grep new_cursors
new_cursors=true
zen@ubClient:~$
zen@ubClient:~$
zen@ubClient:~$ sudo sed -e 's/^new_cursors=true/new_cursors=false/g' -i /etc/xrdp/xrdp.ini
[sudo] zen のパスワード:
zen@ubClient:~$
zen@ubClient:~$ cat /etc/xrdp/xrdp.ini | grep new_cursors
new_cursors=false
zen@ubClient:~$
zen@ubClient:~$ sudo systemctl restart xrdp
zen@ubClient:~$
zen@ubClient:~$ D=/usr/share/ubuntu:/usr/local/share:/usr/share:/var/lib/snapd/desktop
zen@ubClient:~$
zen@ubClient:~$
zen@ubClient:~$
zen@ubClient:~$ cat < ~/.xsessionrc
> export GNOME_SHELL_SESSION_MODE=ubuntu
> export XDG_CURRENT_DESKTOP=ubuntu:GNOME
> export XDG_DATA_DIRS=${D}
> export XDG_CONFIG_DIRS=/etc/xdg/xdg-ubuntu:/etc/xdg
> EOF
zen@ubClient:~$
zen@ubClient:~$
zen@ubClient:~$ sudo usermod -aG xrdp zen
zen@ubClient:~$ sudo emacs /etc/polkit-1/localauthority/50-local.d/xrdp-c
olor-manager.pkla
zen@ubClient:~$ sudo cat /etc/polkit-1/localauthority/50-local.d/xrdp-color-manager.pkla
[Netowrkmanager]
Identity=unix-user:*
Action=org.freedesktop.color-manager.create-device
ResultAny=no
ResultInactive=no
ResultActive=yes
zen@ubClient:~$
zen@ubClient:~$ sudo systemctl restart polkit