プログラムを中心とした個人的なメモ用のブログです。 タイトルは迷走中。
内容の保証はできませんのであしからずご了承ください。

2017/12/22

Windows 7 に OpenSSH をインストールする

event_note2017/12/22 0:57

Windows 版の OpenSSH を Windows 7 にインストールし、他の PC から SSH でアクセスできるようにします。

基本的なやり方は公式ページで解説されています。

環境

インストール方法

ダウンロード

以下から OpenSSH-Win32.zip をダウンロードします。

ダウンロードしたら展開して適当な場所に置きます。
今回は C:\OpenSSH に置きました。

インストール

PowerShell を管理者権限で起動します。

ディレクトリを移動します。

> cd C:\OpenSSH

sshdssh-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

サービスの自動起動

sshdssh-agent を自動で起動するように設定します。

> Set-Service sshd -StartupType Automatic
> Set-Service ssh-agent -StartupType Automatic

sshdssh-agent を開始します。

> net start sshd

以上で完了です。
他の端末から SSH でアクセスできるか試してみましょう。

アンインストール方法

現時点の Windows 版 OpenSSH まだ正式リリース前のものなので、アンインストール方法も一応書いておきます。

PowerShell を管理者権限で起動します。

ディレクトリを移動します。

> cd C:\OpenSSH

アンインストールスクリプトを実行します。

> powershell.exe -ExecutionPolicy Bypass -File uninstall-sshd.ps1

参考 URL