# SSH 接続をテストする

SSH キーを設定し、GitHub に追加すると、接続をテストできます。

SSH 接続をテストする前に、次のことを済ませておく必要があります。

* [既存の SSH キーを確認する](/ja/enterprise-server@3.22/authentication/connecting-to-github-with-ssh/checking-for-existing-ssh-keys)
* [新しい SSH キーを生成する](/ja/enterprise-server@3.22/authentication/connecting-to-github-with-ssh/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent)
* [新しい SSH キーを GitHub アカウントに追加しました](/ja/enterprise-server@3.22/authentication/connecting-to-github-with-ssh/adding-a-new-ssh-key-to-your-github-account)

先立って作成した SSH キーパスフレーズのパスワードを使ってこのアクションを認証する必要があります。 「[SSH キーのパスフレーズを扱う](/ja/enterprise-server@3.22/authentication/connecting-to-github-with-ssh/working-with-ssh-key-passphrases)」を参照してください。

これらのステップを実行してください：

1. <span class="platform-mac">\[ターミナル]</span><span class="platform-linux">\[ターミナル]</span><span class="platform-windows">\[Git Bash]</span> を開きます。

2. 次のように入力します。

   ```shell copy
   ssh -T git@HOSTNAME
   # Attempts to ssh to GitHub
   ```

   以下のような警告が表示される場合があります:

   ```shell
   > The authenticity of host 'HOSTNAME (IP ADDRESS)' can't be established.
   > ED25519 key fingerprint is SHA256:+DiY3wvvV6TuJJhbpZisF/zLDA0zPMSvHdkr4UvCOqU.
   > Are you sure you want to continue connecting (yes/no)?
   ```

3. 表示されるメッセージのフィンガープリントが、Enterprise の公開キー フィンガープリントと一致することを確認します。 その場合は、「`yes`」と入力します。

   ```shell
   > Hi USERNAME! You've successfully authenticated, but GitHub does not
   > provide shell access.
   ```

   <div class="ghd-tool linux">

   このエラー メッセージが表示されることがあります。

   ```shell
   ...
   Agent admitted failure to sign using the key.
   debug1: No more authentication methods to try.
   Permission denied (publickey).
   ```

   これは、特定の Linux ディストリビューションで生じる既知の問題です。 詳しくは、「[エラー: エージェントが署名の失敗を認めた](/ja/enterprise-server@3.22/authentication/troubleshooting-ssh/error-agent-admitted-failure-to-sign)」をご覧ください。

   </div>

   > \[!NOTE]
   > リモート コマンドはコード 1 で終了します。

4. 出力されたメッセージに、あなたのユーザ名が含まれていることを確認します。 "permission denied" というメッセージが表示される場合は、「[エラー: アクセス許可の却下 (公開キー)](/ja/enterprise-server@3.22/authentication/troubleshooting-ssh/error-permission-denied-publickey)」を参照してください。