Powershell経由でOpenSSHをインストールする

When you use ssh <username>@<hostname>.local (or ssh <username>@<IP address>) to connect to your Raspberry Pi, but the following error message appears.

ssh: The term 'ssh' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the
spelling of the name, or if a path was included, verify that the path is correct and try again.

これは、お使いのコンピュータシステムが古すぎて OpenSSH がプリインストールされていないことを意味します。以下のチュートリアルに従って、手動でインストールする必要があります。

  1. Windowsデスクトップの検索ボックスに powershell と入力し、Windows PowerShell を右クリックして、表示されるメニューから 管理者として実行 を選択します。

    ../_images/powershell_ssh.png
  2. 次のコマンドを使用して OpenSSH.Client をインストールします。

    Add-WindowsCapability -Online -Name OpenSSH.Client~~~~0.0.1.0
    
  3. インストール後、次の出力が返されます。

    Path          :
    Online        : True
    RestartNeeded : False
    
  4. 次のコマンドを使用してインストールを確認します。

    Get-WindowsCapability -Online | Where-Object Name -like 'OpenSSH*'
    
  5. これで OpenSSH.Client のインストールが成功したことがわかります。

    Name  : OpenSSH.Client~~~~0.0.1.0
    State : Installed
    
    Name  : OpenSSH.Server~~~~0.0.1.0
    State : NotPresent
    

    警告

    上記のプロンプトが表示されない場合、Windowsシステムがまだ古すぎることを意味し、:ref:`login_windows`のようなサードパーティのSSHツールをインストールすることをお勧めします。

  6. これでPowerShellを再起動し、引き続き管理者として実行します。ここで、ssh コマンドを使用してRaspberry Piにログインすることができ、以前に設定したパスワードの入力を求められます。

    ../_images/powershell_login.png