> For the complete documentation index, see [llms.txt](https://docs.keeper.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.keeper.io/keeperpam/jp/privileged-access-manager/references/setting-up-ssh.md).

# SSHの設定

## 概要 <a href="#overview" id="overview"></a>

サーバーおよび環境の設定は、お客様の責任で行っていただく必要があります。

Secure Shell (SSH) を使用すると、コンピュータへの安全な認証付きのリモートアクセスが可能になります。SSHトラフィックは完全に暗号化されており、デフォルトではポート `22` で実行されます。参考およびテスト用途として、対象オペレーティングシステムでSSHを有効にする手順を以下に示します。

## Linux

Linuxでは、SSH接続を受け入れるためにSSHデーモンが実行されている必要があります。ほとんどのLinuxディストリビューションにはOpenSSHサーバーがインストールされていますが、サービスが有効になっていない場合があります。サービスを有効にし、再起動時に開始するサービスのリストに追加する必要があります。

以下のコマンドを実行して、LinuxシステムでSSHが実行されていることを確認します。

```sh
ps aux | grep sshd
```

SSHが実行されていない場合、OpenSSHをインストールするかSSHを有効にする必要があります。以下のコマンドはUbuntuでの例です。

```bash
apt-get install openssh-server
systemctl enable ssh
systemctl start ssh
```

{% hint style="info" icon="pencil-line" %}

* sshをインストールして有効にするには、sudo権限が必要な場合があります。
* インストールコマンドは、Linuxディストリビューションによって異なる場合があります。
  {% endhint %}

## Windows

通常、WindowsにはSSHがインストールされていませんが、Microsoftが管理するWindows機能パッケージを介して簡単にインストールできます。

* SSHをインストール
* SSHサービスの開始と再起動時の自動起動設定
* ファイアウォールでSSH接続を許可

{% code overflow="wrap" %}

```powershell
# Install OpenSSH
Add-WindowsCapability -Online -Name OpenSSH.Server

# Start service and make sure it automatically starts after reboot.
Start-Service sshd
Set-Service -Name sshd -StartupType 'Automatic'

# Make sure the the firewall will allow SSH connections
if (!(Get-NetFirewallRule -Name "OpenSSH-Server-In-TCP" -ErrorAction SilentlyContinue | Select-Object Name, Enabled)) {
    Write-Output "Firewall Rule 'OpenSSH-Server-In-TCP' does not exist, creating it..."
    New-NetFirewallRule -Name 'OpenSSH-Server-In-TCP' -DisplayName 'OpenSSH Server (sshd)' -Enabled True -Direction Inbound -Protocol TCP -Action Allow -LocalPort 22
} else {
    Write-Output "Firewall rule 'OpenSSH-Server-In-TCP' has been created and exists."
}
```

{% endcode %}

SSH経由で接続するには、新しい[PAMマシン](/keeperpam/jp/privileged-access-manager/getting-started/pam-resources/pam-machine.md)レコードを作成し、接続プロトコルをSSHに設定します。

接続後、`powershell.exe` と入力すると PowerShellコマンドを実行できます。

```
domain\admin@MACHINE C:\Users\Administrator\Desktop>powershell.exe

Windows\system32\conhost.exe - powershell.exeWindows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.

PS C:\Users\Administrator\Desktop> 
```

### Windows Shell <a href="#shell" id="shell"></a>

Windows SSHのデフォルトシェルは PowerShellまたはCMD になります。Keeper RotationではPowerShellコマンドを使用します。デフォルトのシェルがCMDの場合、Keeper Rotationは `PowerShell Invoke-Command -ScriptBlock { COMMANDS }` を介してローテーションコマンドを呼び出します。デフォルトのシェルをPowerShellに変更するには、以下のPowerShellコマンドを呼び出します。

```powershell
# Enable PowerShell in SSH
New-ItemProperty -Path "HKLM:\SOFTWARE\OpenSSH" -Name DefaultShell `
  -Value "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe" `
  -PropertyType String -Force
```

## MacOS

MacOSにはSSHがインストールされていますが、通常は有効になっていません。

UIで有効にするには、**\[一般]** → **\[共有]** パネルで **\[リモートログイン]** を有効にします。

<figure><img src="/files/mTJbhHCl7NwIh4oKuVkg" alt="" width="544"><figcaption></figcaption></figure>

コマンドラインで有効にするには、以下のコマンドを呼び出します。

```bash
$ sudo systemsetup -setremotelogin on
```

{% hint style="info" icon="pencil-line" %}
このコマンドライン方式では、**Full Disk Access**権限が必要です。
{% endhint %}


---

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

```
GET https://docs.keeper.io/keeperpam/jp/privileged-access-manager/references/setting-up-ssh.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.
