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?

Ubuntu24 Hyper-vのコンソールを xrdp と統合して使用する

Last updated at Posted at 2025-03-03

Hyper-V コンソールで拡張セッションが有効にならず、リモートディスクトップ接続していたが、もっと楽な方法はと探していたら Hyper-V コンソールと xrdp を統合する方法があった。

Hyper-V コンソールが xrdp 経由でログインすることができるようになる。

ゲスト側(Ubuntu)

xrdp をインストール

sudo apt update
sudo apt install xrdp xorgxrdp
sudo vim /etc/xrdp/xrdp.ini
port=3389
↓
# vsock でホスト側(拡張セッション側 HvSocket)からの通信を 3389 ポートで待ち受ける(おそらく)
port=vsock://-1:3389

# xrdp 有効化
sudo systemctl enable xrdp

# xrdp 再起動
sudo systemctl restart xrdp

# シャットダウン
sudo shutdown now

ホスト(Windows側)

powershell を管理者で開きコマンド実行

Set-VM -VMName ubuntu24_test -EnhancedSessionTransportType HvSocket

以下のコマンドで拡張セッションを有効にすることで RDP を使えるようにs(おそらく)
Set-VM -VMName <作成した仮想マシン名> -EnhancedSessionTransportType HvSocket
作成した仮想マシン名は、Hyper-V マネージャー画面の仮想マシンの名前

Hyper-V で Ubuntuを起動する

Ubuntu を起動すると画面設定のポップアップが表示されるのでお好みのサイズ(1920*1080)に指定して「接続」をクリック。

Session: Xorg
username: 作成したUbuntuのユーザ名
password: 作成したUbuntuユーザのパスワード

でログインする。

ディスクトップ環境を Gnome-Shell にしたい場合

ディスクトップ環境を Gnome-Shell にしたい場合は、ログイン後に画面の左上をクリックして メニュー>端末 をクリックし以下を xrdp の設定を変更する

この2行を追加する
export GNOME_SHELL_SESSION_MODE=ubuntu
export XDG_CURRENT_DESKTOP=ubuntu:GNOME

sudo vim /etc/xrdp/startwm.sh

#!/bin/sh
# xrdp X session start script (c) 2015, 2017, 2021 mirabilos
# published under The MirOS Licence

# Rely on /etc/pam.d/xrdp-sesman using pam_env to load both
# /etc/environment and /etc/default/locale to initialise the
# locale and the user environment properly.

# 先頭に追加
export GNOME_SHELL_SESSION_MODE=ubuntu
export XDG_CURRENT_DESKTOP=ubuntu:GNOME

if test -r /etc/profile; then
        . /etc/profile
fi

以上

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?