# 非管理対象 Linux クライアント

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

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

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

## 前提条件

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

### 2. App Service Settings

このシナリオでは、次の種類の証明書を登録します ***IntuneUser.***

## Powershell モジュール SCEPmanClient

### 初回要求

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

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

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

### 証明書の更新

PowerShell モジュールを使用して、既存の証明書を更新することもできます。これにより、認証にサービス プリンシパルを使用する必要もなくなります:

```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) スクリプトを使用して、最初に証明書を取得し、さらにそれを検証して、有効期限が近い場合に更新を試みることができます。

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

例:

{% 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&#x26;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 によって実行されるコマンドは、スクリプト/証明書が存在するディレクトリから実行されるとは限らないため、スクリプト/証明書への絶対パスを指定することが重要です。&#x20;


---

# Agent Instructions: 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:

```
GET https://docs.scepman.com/ja/no/api-certificates/self-service-enrollment/unmanaged-linux-client.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
