> For the complete documentation index, see [llms.txt](https://docs.scepman.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.scepman.com/ja/zheng-ming-shu-guan-li/api-certificates/self-service-enrollment/unmanaged-linux-client.md).

# 未管理の Linux クライアント

{% hint style="info" %}
SCEPman バージョン 2.9 以降に適用されます
{% endhint %}

{% hint style="warning" %}
SCEPman Enterprise Edition のみ
{% endhint %}

この方法は、Intune 以外の MDM によって管理されていない、または管理されているユーザーおよびデバイス向けに証明書を登録するために使用できます。

## 前提条件

### 1. セルフサービス登録

証明書を登録するには、ユーザーは資格を確認するために認証されている必要があります。これを設定する方法については、このガイドの手順に従ってください。

{% content-ref url="/pages/445d23611bcf69e4026fabba99f0bb392434f719" %}
[セルフサービス登録](/ja/zheng-ming-shu-guan-li/api-certificates/self-service-enrollment.md)
{% endcontent-ref %}

### 2. App Service の設定

#### 構成

*証明書更新に必要*

SCEPman App Service が mTLS クライアント証明書を受け入れるように構成します。Settings セクションの Configuration ブレードで、Incoming client certificates の Client certificate mode が次に設定されていることを確認します。 ***任意の対話型ユーザー***.

<figure><img src="https://114237723-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LoGejQeUQcw7lqnQ3WX%2Fuploads%2F9UeFFxwefnV8Cb7Zz14u%2Fimage.png?alt=media&amp;token=210ea9b7-ecd5-4b2b-9641-22447246e718" alt=""><figcaption></figcaption></figure>

Client certificate mode を Require または Allow に設定しないでください。そうすると、SCEP エンドポイントでの SCEPman の通常の動作が壊れてしまいます。

#### 環境変数

このシナリオを使用するには、SCEPman アプリ サービスに次の環境変数を設定する必要があります。

#### [AppConfig:DbCSRValidation:Enabled](https://docs.scepman.com/advanced-configuration/application-settings/dbcsr-validation#appconfig-dbcsrvalidation-enabled)

*証明書の登録と更新に必要*

この変数を次に設定します ***true*** 証明書署名要求 (CSR) の検証を有効にするには、

#### [AppConfig:DbCSRValidation:AllowRenewals](https://docs.scepman.com/advanced-configuration/application-settings/dbcsr-validation#appconfig-dbcsrvalidation-allowrenewals)

*証明書更新に必要*

この変数を次に設定します ***true*** 証明書の更新を有効にするには、

#### [AppConfig:DbCSRValidation:ReenrollmentAllowedCertificateTypes](https://docs.scepman.com/advanced-configuration/application-settings/dbcsr-validation#appconfig-dbcsrvalidation-reenrollmentallowedcertificatetypes)

*証明書更新に必要*

この変数を、更新を許可する証明書の種類のコンマ区切りリストに設定します。使用可能な証明書の種類の一覧については、リンク先の変数のドキュメントを参照してください。

例: ***Static,IntuneUser,IntuneDevice***

このシナリオでは、次の種類の証明書が登録されます ***IntuneUser。***

## PowerShell モジュール SCEPmanClient

### 初回要求

Linux デバイスで証明書を要求するには、SCEPmanClient PowerShell モジュールを使用できます:

```powershell
New-SCEPmanCertificate -Url 'scepman.contoso.com' -SubjectFromUserContext -SaveToFolder '~/certs/'
```

その後、ユーザーはブラウザー セッションで対話的にログインする必要があり、ログインしたアカウント用の証明書が作成されます。

### 証明書の更新

PowerShell モジュールを使用して、既存の証明書を更新することもできます。これにより、認証に service principal を使用する必要もなくなります:

```powershell
$Parameters = @{
    'CertificateFromFile' = '~/certs/john.doe@contoso.com.pem'
    'KeyFromFile'         = '~/certs/john.doe@contoso.com.key'
    'SaveToFolder'        = '~/certs/'
}

New-SCEPmanCertificate @Parameters
```

## 登録および更新スクリプト

PowerShell モジュールが利用できない場合は、 [enrollrenewcertificate.sh](https://github.com/scepman/csr-request/blob/main/enroll-certificate/enrollrenewcertificate.sh) スクリプトを使って、証明書を最初に取得し、その証明書を検証し、期限切れが近い場合には更新を試みることができます。

### **クライアントの前提条件**

次の前提条件は、Enrollment REST API を使用できるようにするために、実行クライアント/ホスト上に存在している必要があります。

#### [**Azure CLI**](https://learn.microsoft.com/en-us/cli/azure/install-azure-cli) **（バージョン 2.61 以上）**

Azure CLI は、登録するユーザーの認証を行い、対象資格を確認してアクセス トークンを取得するために使用されます。

#### cURL

作成した CSR を SCEPman Enrollment API エンドポイントに送信し、証明書を受け取るために使用します。

#### OpenSSL

OpenSSL は、証明書の登録または更新のための秘密鍵を生成し、CSR を作成するために使用されます。

例:

{% code overflow="wrap" %}

```bash
./enrollrenewcertificate.sh -u https://scepman.contoso.net/ api://b7d17d51-8b6d-45eb-b42b-3dae638cd5bc/Cert.Enroll ~/certs/ "myCertificate" "myKey" 30
```

{% endcode %}

#### 1. コマンド

スクリプトの動作を定義します

次のいずれかを指定できます:

**-u** 初回登録か更新かを自動判定するユーザー証明書用

**-d** 初回登録か更新かを自動判定するデバイス証明書用

**-r** 更新用

**-w** ユーザーの初回登録用

**-x** デバイスの初回登録用

{% hint style="warning" %}
デバイス証明書を登録または更新する場合、DeviceId は既定で次から読み取りが試行されます *\~/.config/intune/registration.toml* そして、認証済みユーザーは構成済みのオブジェクトの所有者と一致する必要があります [DeviceDirectory](https://docs.scepman.com/advanced-configuration/application-settings/intune-validation#appconfig-intunevalidation-devicedirectory)
{% endhint %}

#### 2. App Service URL

SCEPman アプリ サービスの URL。

*例: "<https://scepman.contoso.net/>"*

#### 3. API\_SCOPE

これは、環境内の ***SCEPman-api*** アプリ登録で作成できる API スコープです。

ユーザーには希望する同意ダイアログが表示され、その後セルフサービス機能を使用できるようになります。

*例: "api://*&#x62;7d17d51-8b6d-45eb-b42b-3dae638cd5bc/Cert.Enrol&#x6C;*"*

<figure><img src="https://114237723-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LoGejQeUQcw7lqnQ3WX%2Fuploads%2FKWdXwi8JnKGy27tU384e%2Fimage.png?alt=media&amp;token=5173dc4b-8981-40e9-8875-e932078c6667" alt=""><figcaption></figcaption></figure>

#### 4. 証明書ディレクトリ

証明書が作成される、または更新のために読み取られるディレクトリです。

*例: \~/certs/*

#### 5. 証明書ファイル名

更新用に作成または読み取られる証明書のファイル名（拡張子なし）です。

*例: "myCertificate"*

#### 6. 秘密鍵ファイル名

更新用に作成または読み取られる秘密鍵のファイル名です。

*例: "myKey"*

#### 7. 更新しきい値

スクリプトが更新処理を開始するために、証明書の有効期限まであと何日である必要があるかを表します。

*例: 30*

### 注意事項

* このスクリプトは生成されたキーを暗号化しません（これにはパスフレーズの入力が必要なため、自動更新を可能にするため暗号化は省略されています）。
* Certificate Master からパスフレーズで保護された証明書を更新する場合は、それらを更新するためにこのパスフレーズを入力する必要があります。

## 自動更新の設定

上記の bash スクリプトを実行して、証明書がすでに登録されていることを検出すると、mTLS を使用してその証明書を更新します（有効期限が近い場合）。スクリプトを定期的に実行すれば、有効期限が近づいたときに証明書が更新されるようになります。これを実現するために cronjob を設定できます。以下のコマンドは、その方法の一例です。これは、コマンドを毎日（システムの電源が入っている場合）実行する cronjob と、再起動時にコマンドを実行する cronjob を設定します。

<pre data-overflow="wrap"><code><strong>(crontab -l ; echo @daily /path/to/enrollrenewcertificate.sh -u https://scepman.contoso.net/ api://b7d17d51-8b6d-45eb-b42b-3dae638cd5bc/Cert.Enroll /home/user/certs/ "myCertificate" "myKeyName" 30 ; echo @reboot /path/to/enrollrenewcertificate.sh -u https://scepman.contoso.net/ api://b7d17d51-8b6d-45eb-b42b-3dae638cd5bc/Cert.Enroll /home/user/certs/ "myCertificate" "myKeyName" 30 ) | crontab -
</strong></code></pre>

Cron によって実行されるコマンドは、必ずしもスクリプト/証明書が置かれているディレクトリから実行されるとは限らないため、スクリプト/証明書への絶対パスを指定することが重要です。


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.scepman.com/ja/zheng-ming-shu-guan-li/api-certificates/self-service-enrollment/unmanaged-linux-client.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
