SSH Client には ssh コマンドが必要 (Windows10 付属のは動く。puttyは使えない)
.ssh/config の ProxyCommand には "ssh" でなく "ssh.exe" と書くべし
ssh-agent はプロセス起動でなく、サービスとして起動する
ssh-agent はバージョンが古くて自動で鍵認証できないので、最新版を自分で入れる必要あり (7.9以上が必要)
Windows10付属のSSH Clientのインストール
.ssh/ に秘密鍵を作る (puttyから流用)
putty genを起動
秘密鍵を読み込む
秘密鍵の変換: [Conversions] > [Export OpenSSH key] > ( C:\Users\youruser\.ssh\id_rsa
に保存)
.ssh以下を0700(0600): Explore > [プロパティ] > [セキュリティー] > [詳細設定] > [継承の無効化] (自分だけアクセスできる状態にする)
VSCode から設定画面が開ける (configのファイル名ミスが防げる)
run VSCode
run Remote-SSH: Open Configuration File... in the Command Palette (F1)
select the SSH config file you wish to change, and add (or modify) a host entry in the config file
Host name-of-ssh-host-here
User your-user-name-on-host
HostName host-fqdn-or-ip-goes-here
IdentityFile ~/.ssh/id_rsa
# ProxyCommand C:\Windows\System32\OpenSSH\ssh.exe -W %h:%p {proxy-host}
例: (local) > user1@entrance.example.com:1234
> user2@office.example.com:5678
> user3@dev.example.com
Host *
StrictHostKeyChecking no
TCPKeepAlive yes
ForwardAgent yes
Host entrance
User user1
HostName entrance.example.com
Port 1234
IdentityFile ~/.ssh/id_rsa
Host office
User user2
HostName office.example.com
Port 5678
ProxyCommand C:\Windows\System32\OpenSSH\ssh.exe -W %h:%p entrance
Host dev
User user3
HostName dev.example.com
ProxyCommand C:\Windows\System32\OpenSSH\ssh.exe -W %h:%p office
Windows10 付属の OpenSSH のバージョンは 7.7 (2020/09現在)
7.9以上でないと、ssh-agent で認証できない (新しい鍵交換アルゴリズムに対応しておらず、弾かれる)
githubにある最新は 8.1 なのでこれを入れる (2020/09現在)
> ssh -V
OpenSSH_for_Windows_7.7p1, LibreSSL 2.6.5
> ssh {remote-server}
warning: agent returned different signature type ssh-rsa (expected rsa-sha2-512)
Enter passphrase for key ...
https://github.com/PowerShell/Win32-OpenSSH/releases から最新版の OpenSSH-Win64.zip
をダウンロード
解凍して、フォルダ名を OpenSSH
にする
(万一のために)現在versionを保存 C:\Windows\System32
にて OpenSSH
を OpenSSH-bundled
にリネーム (名前は何でも良い)
2のフォルダを C:\Windows\System32
に移動
cmdでバージョン確認
> ssh -V
OpenSSH_for_Windows_8.1p1, LibreSSL 2.9.2
[Windows管理ツール] > [サービス] > [OpenSSH Authentication Agent] > [プロパティ]
→ [自動] > [適用] > [開始] > [OK]
> ssh-add -l
The agent has no identities.
> ssh-add id_rsa
Enter passphrase for id_rsa:
Identity added: id_rsa (id_rsa)
> ssh-add -l
2048 SHA256:...