Windows 版の OpenSSH を Windows 7 にインストールし、他の PC から SSH でアクセスできるようにします。
基本的なやり方は公式ページで解説されています。
環境
- Windows 7 Professional 32bit
- Win32-OpenSSH 0.0.24.0
インストール方法
ダウンロード
以下から OpenSSH-Win32.zip
をダウンロードします。
ダウンロードしたら展開して適当な場所に置きます。
今回は C:\OpenSSH
に置きました。
インストール
PowerShell を管理者権限で起動します。
ディレクトリを移動します。
> cd C:\OpenSSH
sshd
と ssh-agent
をインストールします。
> powershell -ExecutionPolicy Bypass -File install-sshd.ps1
鍵を作成します。
> .\ssh-keygen.exe -A
> powershell -ExecutionPolicy Bypass '.\FixHostFilePermissions.ps1 -Confirm:$false'
設定
ファイアウォールの設定
TCP の 22 番ポートを開け、SSH で接続できるようにします。
> netsh advfirewall firewall add rule name=SSHPort dir=in action=allow protocol=TCP localport=22
サービスの自動起動
sshd
と ssh-agent
を自動で起動するように設定します。
> Set-Service sshd -StartupType Automatic
> Set-Service ssh-agent -StartupType Automatic
sshd
と ssh-agent
を開始します。
> net start sshd
以上で完了です。
他の端末から SSH でアクセスできるか試してみましょう。
アンインストール方法
現時点の Windows 版 OpenSSH まだ正式リリース前のものなので、アンインストール方法も一応書いておきます。
PowerShell を管理者権限で起動します。
ディレクトリを移動します。
> cd C:\OpenSSH
アンインストールスクリプトを実行します。
> powershell.exe -ExecutionPolicy Bypass -File uninstall-sshd.ps1