LoginSignup
13
18

More than 3 years have passed since last update.

Proxy下のWindows10でOpenSSHする

Posted at

経緯

Visual Studio Code Preview版に、Remoteの拡張機能が2019/5/2にリリースされた。

インテリセンスやシンタックスハイライトなど使えて便利そう。
AWSサーバにSSHしてみよう...
あれつながらない。

要約

  • ~/.ssh/configのProxyCommandはフルパスで書く
  • キーファイルの配置場所は~/以下にする

設定

以下の設定を追加。

~/.ssh/config
Host AWSServer
  User ec2-user
  HostName {hostName}
  Port {PortNumber}
  IdentityFile "C:\work\ssh-key\{keyFileName.pem}"
  ProxyCommand connect.exe -H {proxyServer}:{port} %h %p

VSCodeより接続すると、以下のエラーが発生。

> posix_spawn:No such file or directory

ProxyCommandはフルパス使って書きましょう。
StackOverflow

~/.ssh/config
  ProxyCommand C:\Program Files\Git\mingw64\bin\connect.exe -H {proxyServer}:{port} %h %p

上記エラーは解消するも、以下のエラーが発生。

> @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
> @         WARNING: UNPROTECTED PRIVATE KEY FILE!          @
> @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
> Permissions for 'C:\\work\\ssh-key\\{keyFileName.pem}' are too open.
> ...

linuxやmacでは、"chmod 600 {keyFileName.pem}"でパーミッション変えればいけるのだが、
Windowsでは配置先をユーザーフォルダ以下に置かなければならない。

なので、keyファイルの場所とconfigを変更。

~/.ssh/config
  IdentityFile "C:\Users\{userName}\ssh-key\{keyFileName.pem}"

ぶじつながった。

13
18
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
13
18