Introduction

前回 は Windows マシンを Entra ID に参加させた。
今回は Ubuntu マシンを参加させてみる。
ただし、結論としてドメインユーザでログインはできるが、マシンそのものを Entra ID の管理下に置くことはできない点に注意。

Description

公式の Install authd and brokers for cloud identity providers を参考にする。

検証環境は

  • Ubuntu 24.04 LTS

1. authd のインストール

1
2
$ sudo add-apt-repository ppa:ubuntu-enterprise-desktop/authd && sudo apt update
$ sudo apt install -y authd gnome-shell yaru-theme-gnome-shell

2. identity broker のインストール

identity broker とは認証プロバイダ (identity provider) とのインターフェースを提供するサービス。
Google IAMMicrosoft Entra ID のタブがあるので後者を選択。

1
$ sudo snap install authd-msentraid

3. authd の設定準備

1
2
$ sudo mkdir -p /etc/authd/brokers.d/
$ sudo cp /snap/authd-msentraid/current/conf/authd/msentraid.conf /etc/authd/brokers.d/

4. アプリケーションの登録

identity brokerOAuth 2.0 アプリケーションとして Entra ID に登録していく。

Azure ポータル から Microsoft Entra 管理センター に進み、アプリの管理 を押下。

Application Registration

新規登録 を押下。

Application Registration

名前 を入力 (何でもよい)、この組織ディレクトリのみに含まれるアカウント (XXXX YYYY のみ - シングルテナント) を選択し、登録 を押下。

Application Registration

アプリケーションが作成される
アプリケーション (クライアント) ID**、ディレクトリ (テナント) ID** は と、後述の設定ファイルの編集の際に使用するのでメモしておく。

次に API アクセス許可 を押下。

Application Registration

アクセス許可の追加 を押下

API Permissions

Microsoft Graph を押下

API Permissions

委任されたアクセスの許可 を押下

API Permissions

OpenID アクセス許可 内の openid をチェック

API Permissions

GroupMember 内の GroupMember.ReadAll をチェックして、アクセス許可の追加 を押下

API Permissions

Authentication (Preview) を押下

API Permissions

ここでバグなのか、保存 ボタンが見当たらないため、画面上部の Welcome to the new and improved experience for authentication. To switch to the old experience, please click here. に従い、古い UI に変更する。
そして、パブリック クライアント フローを許可する トグルを 有効 に変更して 保存 ボタンを押下。

API Permissions

5. broker の設定

/var/snap/authd-msentraid/current/broker.conf を編集。
初期設定が下記になっている。

1
2
3
4
[oidc]
issuer = https://login.microsoftonline.com/<ISSUER_ID>/v2.0
client_id = <CLIENT_ID>
# force_provider_authentication = false

下記のように編集していく (GUID の値は適当)。

1
2
3
4
5
6
7
  [oidc]
- issuer = https://login.microsoftonline.com/<ISSUER_ID>/v2.0
+ issuer = https://login.microsoftonline.com/64b4f7aa-19f2-4d54-ba34-c6b21dd181b8/v2.0
- client_id = <CLIENT_ID>
+ client_id = 64b4f7aa-19f2-4d54-ba34-c6b21dd181b8
- # force_provider_authentication = false
+ force_provider_authentication = false
  • アプリケーション (クライアント) ID
  • ディレクトリ (テナント) ID

になるため、登録したアプリの概要画面で再度確認しておく。

注意
  • を逆に入力すると、ログイン時に Microsoft Entra ID を選択しても何も起こらず、困ることになるので要注意 (戒め)
  • force_provider_authenticationtrue にすると、インターネットへの接続に問題があるときログインができなくなる可能性があるので注意。

6. 許可されたユーザーを設定する

マシンを利用する利用者や所有者を制御する場合の設定。
自分は特に必要ではなかったので省略。

参考: 許可されたユーザーを設定する

7. 設定の反映

1
$ sudo systemctl restart authd

ブローカーの構成が更新された場合は、ブローカーを再起動する必要もあります。

1
$ sudo snap restart authd-msentraid

8. GUI からドメインユーザでログイン

ログイン画面に移動し、Not listed? を選択

Login

ドメインユーザのメールアドレスを入力し Enter を押下

Login

ブローカーの選択が表示されるので Microsoft Entra ID を選択

Login

QR コードが表示されるのでスマートフォンのカメラで認識しブラウザを開くか、https://microsoft.com/devicelogin に手動でアクセス。
(Microsoft Authenticator の QR コードスキャンではない点に注意)

Login

先の画面の Login code を入力

Login

再度、ドメインユーザのメールアドレスを入力

Login

ドメインユーザのパスワードを入力

Login

MFA 認証が行われるので適宜対処

Login

承諾 を押下

Login

ブラウザを閉じてログイン画面に戻る

Login

オフライン時のためのパスワードを作成

Login

もし、辞書にあるような単純なパスワードを使用するとエラーになるのでやり直し

Login

パスワード作成後は、OS 新規インストールのツアーガイドが表示され、いつも通りのデスクトップが表示される。
ターミナルから whoamiecho $HOME を実行するとドメインユーザであり、対応したホームディレクトリが生成されていることがわかる。

Login

以上でドメインユーザでのログインまでが完了した。

冒頭に上げたように、authd を使っても、 Entra ID の管理デバイス対象にはならない点には注意が必要。
Microsoft Entra 管理センター でデバイス一覧を確認してもデバイスが増えていないことからも分かる。

9. SSH からドメインユーザでログイン

事前に準備が必要。
/etc/ssh/sshd_config.d/authd.conf を作成し下記を記載。

1
2
UsePAM yes
KbdInteractiveAuthentication yes

設定を反映するために ssh デーモンを再起動

1
$ sudo systemctl restart ssh

SSH でログインしてみる。
IPの前に普通にユーザ名とドメインを結合した値をユーザとして指定するだけで特別なことは無い。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
ssh -t-takeuchi@hogehoge.jp@192.168.11.35
== Local Password Authentication ==
Enter 'r' to cancel the request and go back to select the authentication method
(t-takeuchi@hogehoge.jp@192.168.11.35) Enter your local password:
>
== Authentication method selection ==
1. Local Password Authentication
2. Device Authentication
Or enter 'r' to go back to choose the provider
(t-takeuchi@hogehoge.jp@192.168.11.35) Choose your authentication method:
> 2
== Device Authentication ==
Access "https://microsoft.com/devicelogin" and use the provided login code
https://microsoft.com/devicelogin
NRWPY264Y

1. Wait for authentication result
2. Request new login code
Or enter 'r' to go back to select the authentication method
(t-takeuchi@hogehoge.jp@192.168.11.35) Choose action:
> 1
== Define your local password ==
Enter 'r' to cancel the request and go back to choose the provider
(t-takeuchi@hogehoge.jp@192.168.11.35) Create a local password:
>
(t-takeuchi@hogehoge.jp@192.168.11.35) Confirm Password:
>
Welcome to Ubuntu 24.04 LTS (GNU/Linux 6.14.0-27-generic x86_64)

* Documentation: https://help.ubuntu.com
* Management: https://landscape.canonical.com
* Support: https://ubuntu.com/pro

1 device has a firmware upgrade available.
Run `fwupdmgr get-upgrades` for more information.


Expanded Security Maintenance for Applications is not enabled.

261 updates can be applied immediately.
1 of these updates is a standard security update.
To see these additional updates run: apt list --upgradable

Enable ESM Apps to receive additional future security updates.
See https://ubuntu.com/esm or run: sudo pro status


1 updates could not be installed automatically. For more details,
see /var/log/unattended-upgrades/unattended-upgrades.log

The programs included with the Ubuntu system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Ubuntu comes with ABSOLUTELY NO WARRANTY, to the extent permitted by
applicable law.


1 device has a firmware upgrade available.
Run `fwupdmgr get-upgrades` for more information.

注意するのは Choose action と聞かれた際に、 1 を入力してから認証をしないと認証に失敗してしまう点にある。