0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Ubuntu Server 24.10 に高速 RDP 接続

Last updated at Posted at 2025-02-12

Azure で Linux コンテナーを使えるデスクトップ環境がほしくなり、Ubuntu で作ってみました。

Azure の公式ドキュメントでは xfce4 + xrdp での構成方法が紹介されていますが、xrdp は遅かったので、ubuntu-desktop-minimal (同梱の GNOME Remote Desktop) を使った RDP 接続の構成方法をご紹介します。

VM の作成

Ubuntu Server 24.10 の VM を作成します。24.10 (GNOME 47) 以降でないと、通信不良やスリープによりリモート デスクトップが切断された瞬間に、デスクトップで開いていたプロセスが全て強制終了されてしまうため使いづらいです。

ARM64 か x64 かは迷うところですが、価格が安いことから、ここでは ARM64 を選びました。価格は D4pls (ARM64, 8GiB) なら ¥17,511/月、D4s (x64, 16GiB) だと ¥27,142/月 です。

準備をする

まずは SSH で接続して RDP に必要なパッケージをインストールし、設定していきます。ユーザー名は azureuser としています。

$ sudo apt update
$ sudo apt full-upgrade
$ sudo reboot
$ sudo apt install ubuntu-desktop-minimal ibus-mozc mozc-utils-gui
$ sudo systemctl disable systemd-networkd.service
$ sudo -u gnome-remote-desktop sh -c 'mkdir -p ~/.local/share/gnome-remote-desktop/'
$ sudo -u gnome-remote-desktop sh -c "openssl req -new -newkey rsa:4096 -days 720 -nodes -x509 -subj /C=SE/ST=NONE/L=NONE/O=GNOME/CN=$(hostname) -out ~/.local/share/gnome-remote-desktop/tls.crt -keyout ~/.local/share/gnome-remote-desktop/tls.key"
$ sudo grdctl --system rdp set-tls-key ~gnome-remote-desktop/.local/share/gnome-remote-desktop/tls.key
$ sudo grdctl --system rdp set-tls-cert ~gnome-remote-desktop/.local/share/gnome-remote-desktop/tls.crt
$ sudo grdctl --system rdp set-credentials # 画面に繋ぐためのユーザー名、パスワードを指定
$ sudo grdctl --system rdp enable
$ sudo systemctl enable --now gnome-remote-desktop.service
$ sudo passwd azureuser # 画面に繋いだ後ログインするためにパスワードが必要
$ sudo chfn -f "Azure User" azureuser # ログイン画面に表示される full name を設定。azureuser の箇所は VM 作成時に作成したユーザー名を指定。
$ sudo reboot

ibus-mozc は日本語入力のため、mozc-utils-gui はその設定画面のためのパッケージです。

Configuring kdump-tools のダイアログでは Yes としました。

systemd-networkd.service は Ubuntu desktop のインストール後は、無効化しないと起動が遅くなってしまいます。無効化時に Disabling 'systemd-networkd.service', but its triggering units are still active: systemd-networkd.socket というメッセージが出ます。下記 Ask Ubuntu の回答を参考にしました。

証明書の作成や grdctl コマンドは、下記 GNOME Remote Desktop の公式の記述を参考にしました。CN が gnome.org になっていた箇所は、ホスト名に変更しました。

grdctl コマンドの実行時に Init TPM credentials failed because Failed to initialize transmission interface context: tcti:IO failure, using GKeyFile as fallback. というメッセージが出ます。

接続する

grdctl rdp set-credentials で設定したユーザー名とパスワードで接続すると、以下のメッセージが表示されます。

GNOME Remote Desktop Handover Daemon

This connection is insecure.
Do you want to continue with an insecure connection? To make it secure set "use redirection server name:i:1" in the RDP config file.

このメッセージは、リモート デスクトップの接続ファイル (拡張子 rdp) を保存して、use redirection server name:i:0 と書かれた行を use redirection server name:i:1 にすると消すことができます。

あとは、Ubuntu のユーザー名とパスワードでログインして使うだけです。

トラブル

全体的な不安定さ

全体的に不安定で、再接続してみたり、再起動してみたりすると、なぜかトラブルが解消することがあります。

macOS の Windows App から接続できない

一旦接続設定を作成し、それをエクスポートして、use redirection server name:i:1 に設定を変更して rdp ファイルをダブルクリックすれば接続できました。

Azure Bastion のブラウザー画面で RDP で接続できない

Windows のリモート デスクトップとは色々と違うので、仕方ないのでしょう。

az network bastion rdp で接続できない

az network bastion rdp --name $bastionName --resource-group $resourceGroupName --target-resource-id $vmID --configure

で Windows から接続しようとしたところ、以下のメッセージが表示されて接続できませんでした。ゲートウェイ サーバーとして使用される Azure Bastion との相性が悪いのでしょうか?

リモート デスクトップ接続

デバイスからリモート リソースを使用できません。接続を確認してもう一度やり直すか、ネットワーク管理者に問い合わせてください。

ゲートウェイ サーバーを使わずに、以下のコマンドで tunneling して localhost:13389 に接続することは可能でした。

az network bastion tunnel --name $bastionName --resource-group $resourceGroupName --target-resource-id $vmID --port $localPort --resource-port $remotePort

変数で書いた部分は実際の値が入るようにしてご利用ください。

キーボード レイアウトが英語になっている

左下の Show Apps > Settings > Keyboard の Input Sources の Add Input Source... から Japanese を Add し、これを使うようにすると解消します。

たまに ` が入力され続ける

` が入力され続ける問題は Settings の Keyboard で English (US) や Japanese (Mozc) を使うと発生するようで、Japanese を使うようにしたら直りました。

キーボード レイアウトを日本語にすると | が入力できない

現状、どうしようもなさそうです。

` が入力され続ける問題も含め、こちらでアクティブにやり取りされているので、じきに修正されることを期待しています。

Passkey での認証ができない

Trusted launch にしても TPM が使えていないのか、passkey での認証ができないため、他の方法で認証する必要があります。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?