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?

nanoMDMについて

0
Last updated at Posted at 2026-11-26

業務でMicroMDMを使用していたところ、以下の記載があったため、NanoMDMについて調べてみました。

NanoMDM (and the Nano-suite of projects) is the new direction we’re currently focused on. The MicroMDM "v1" project has been in maintenance mode for over a year and is now deprecated.

目次

  1. MDMとは?
  2. NanoMDMとMicroMDMの違い
  3. 実際に使ってみる
  4. 終わりに
  5. 参考にしたサイト

1. MDMとは?

MDMとは「Mobile Device Management」の略で、スマートフォン、タブレット、ノートPCなどの端末を組織で一元管理する仕組みです。
端末情報やセキュリティ状態を把握できるほか、Wi-FiやVPNなどの設定、業務アプリの配布・更新・削除、利用制限、紛失時のロックや遠隔消去などを一括で行うことができます。

2. NanoMDMとMicroMDMの違い

NanoMDMとMicroMDMは、どちらもAppleデバイス向けのオープンソースMDMサーバーです。本番環境ではApple DeveloperアカウントやMDM用の証明書が必要になりますが、テストや実験目的であれば、mdmcert.downloadからテスト用証明書を取得して動作を確認できます。

NanoMDM MicroMDM
ターゲット 開発者向け 運用担当者向け
機能 基本的なMDM通信・コマンド処理に絞られる コマンド管理、プロファイル、ADE(旧DEP)、Webhook、APIなどを備える
導入・運用 必要な機能を自分で実装する必要がある 比較的すぐに利用できる
カスタマイズ性 高い NanoMDMより限定的
対象 独自のMDMシステムを開発したい場合 既存の機能を利用して運用したい場合
現在の位置づけ 新しい開発の方向性 非推奨・メンテナンスモード

このように、MicroMDMはすぐに利用できる実用性を重視したMDMサーバーであるのに対し、NanoMDMは必要最小限の機能に絞られた開発者向けのMDMサーバーです。独自のMDMシステムを構築する場合は、NanoMDMが適しています。

3. 実際に使ってみる

Windows 11のWSL2でNanoMDMを起動し、Macを登録して端末情報を取得します。

NanoMDMを起動するだけではMacを登録できません。SCEPサーバー、APNs証明書、HTTPSで接続できるURL、登録プロファイルが必要です。

  • MacのMDM証明書を発行するSCEPサーバー
  • Apple Push Notification service(APNs)用の証明書と秘密鍵
  • MacからアクセスできるHTTPS URL
  • MacにインストールするMDM登録プロファイル

この章では動作確認を目的とした簡単な構成にしています。本番環境で使う場合は、証明書の管理やアクセス制御、データの保存方法などを別途検討します。

3.1 WSLとUbuntuの準備

PowerShellでUbuntuをインストールします。

wsl --install -d Ubuntu

インストール済みの場合は、次で起動します。

wsl -d Ubuntu

3.2 NanoMDMとSCEPを準備する

UbuntuでNanoMDMをビルドします。

sudo apt update
sudo apt install -y git golang openssl python3 curl unzip

cd ~
git clone https://github.com/micromdm/nanomdm.git
cd nanomdm
go build -o nanomdm ./cmd/nanomdm

SCEPは公式リリースのLinux用バイナリを使用します。

mkdir -p ~/scep

cd /tmp
curl -fL \
  https://github.com/micromdm/scep/releases/download/v2.3.0/scepserver-linux-amd64-v2.3.0.zip \
  -o scepserver.zip

mkdir -p /tmp/scepserver-release
unzip -o scepserver.zip -d /tmp/scepserver-release
cp /tmp/scepserver-release/scepserver-linux-amd64 ~/scep/scepserver
chmod +x ~/scep/scepserver

SCEP用のCAを作成します。

mkdir -p ~/nanomdm-data/scep
~/scep/scepserver ca -init -depot ~/nanomdm-data/scep

3.3 SCEPとNanoMDMを起動する

Ubuntuのターミナルを2つ開きます。

1つ目のターミナルでSCEPを起動します。

~/scep/scepserver \
  -depot ~/nanomdm-data/scep \
  -http-addr 0.0.0.0:8080 \
  -challenge nanomdm \
  -debug

2つ目のターミナルでNanoMDMを起動します。

cd ~/nanomdm
mkdir -p ~/nanomdm-data/dbkv

./nanomdm \
  -ca ~/nanomdm-data/scep/ca.pem \
  -api nanomdm \
  -listen 0.0.0.0:9000 \
  -storage filekv \
  -storage-dsn ~/nanomdm-data/dbkv \
  -debug \
  -dump

この2つのターミナルは、Macの登録が終わるまで開いたままにします。

3.4 APNs証明書を登録する

Apple MDM Push Certificateと、同じCSRから作成した秘密鍵を用意します。SCEP用のca.pemやca.keyは使いません。

PUSH_CERT="/mnt/c/Users/<Windowsユーザー名>/Downloads/MDM_..._Certificate.pem"
PUSH_KEY="$HOME/mdmcert-new/mdmcert.download.push.key"

NanoMDMへ登録します。

cat "$PUSH_CERT" "$PUSH_KEY" |
curl -T - \
  -u nanomdm:nanomdm \
  http://127.0.0.1:9000/v1/pushcert

レスポンスのtopicを控えておきます。

{
  "not_after": "2027-...",
  "topic": "com.apple.mgmt.External.xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
}

3.5 Nginxとngrokを設定する

Nginxをインストールします。

sudo apt update
sudo apt install -y nginx

/etc/nginx/sites-available/nanomdmを作成し、次の内容にします。

server {
    listen 8088;
    server_name _;

    location /scep {
        proxy_pass http://127.0.0.1:8080;
    }

    location / {
        proxy_pass http://127.0.0.1:9000;
    }
}

設定を有効にします。

sudo ln -sf /etc/nginx/sites-available/nanomdm \
  /etc/nginx/sites-enabled/nanomdm
sudo nginx -t
sudo service nginx restart

ngrokをインストールします。

cd /tmp
curl -fsSL \
  https://bin.ngrok.com/c/bNyj1mQVY4c/ngrok-v3-stable-linux-amd64.tgz \
  -o ngrok.tgz
tar -xzf ngrok.tgz
sudo install -m 0755 ngrok /usr/local/bin/ngrok

Authtokenを設定し、8088番ポートを公開します。

ngrok config add-authtoken "取得したAuthtoken"
ngrok http 8088

表示されたForwardingのURLを控えます。

https://xxxxx.ngrok-free.dev -> http://localhost:8088

3.6 MacをNanoMDMに登録する

NanoMDMのサンプルプロファイルを取得します。

cd ~/nanomdm
curl -L \
  https://raw.githubusercontent.com/micromdm/nanomdm/main/docs/enroll.mobileconfig \
  -o enroll.mobileconfig

ngrokのURLと、APNs証明書登録時のtopicを設定します。

BASE_URL="https://xxxxx.ngrok-free.dev"
TOPIC="com.apple.mgmt.External.xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"

sed -i \
  -e "s|https://mdm.example.org/scep|${BASE_URL}/scep|g" \
  -e "s|SCEP-CHALLENGE-HERE|nanomdm|g" \
  -e "s|https://mdm.example.org/mdm|${BASE_URL}/mdm|g" \
  -e "s|com.apple.mgmt.External.YOUR-PUSH-TOPIC-HERE|${TOPIC}|g" \
  enroll.mobileconfig

プロファイルをWindowsのDownloadsへコピーします。

cp enroll.mobileconfig \
  /mnt/c/Users/<Windowsユーザー名>/Downloads/

このファイルをMacへ転送して開き、プロファイルをインストールします。Macでは、必要に応じて次の場所から承認します。

システム設定 → 一般 → デバイス管理

NanoMDMのログにAuthenticateとTokenUpdateが表示されれば登録完了です。

service=nanomdm msg=TokenUpdate id=... type=Device

macOSによってはtype=Userと表示され、idがデバイスID:ユーザーIDの形式になります。その場合、コマンド送信には:より前のデバイスIDを使います。

3.7 Macの端末情報を取得する

DeviceInformationコマンドを作成します。

cd ~/nanomdm

python3 tools/cmdr.py DeviceInformation \
  DeviceName \
  OSVersion \
  BuildVersion \
  ModelName \
  Model \
  ProductName \
  SerialNumber \
  DeviceCapacity \
  AvailableDeviceCapacity \
  > device-info.plist

登録ログに表示されたデバイスIDを指定します。

curl -T device-info.plist \
  -u nanomdm:nanomdm \
  "http://127.0.0.1:9000/v1/enqueue/<デバイスID>"

次のようなレスポンスが返れば、コマンドは受け付けられています。

{
  "request_type": "DeviceInformation",
  "command_uuid": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
}

しばらくすると、NanoMDMの-dumpログにMacからのレスポンスが表示されます。

<key>QueryResponses</key>
<dict>
  <key>DeviceName</key>
  <string>My Mac</string>
  <key>OSVersion</key>
  <string>macOS 15.x</string>
  <key>SerialNumber</key>
  <string>XXXXXXXXXXX</string>
</dict>

これで、WSL上のNanoMDMからMacのOSバージョン、モデル名、シリアル番号、ディスク容量などを取得できます。

終わりに

今回はSCEPサーバーやAPNs証明書の準備、Macの登録から始めたため、端末情報を取得するまでに時間がかかりました
一度環境を整えてMacを登録しておけば、次回からはNanoMDMを起動し、DeviceInformationコマンドを送るだけで情報を取得できるため、検証用の環境としても使いやすいと感じました。

参考にしたサイト

https://github.com/micromdm/nanomdm/tree/main
https://micromdm.io/

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?