LoginSignup
2
0

More than 3 years have passed since last update.

Visual Studio CodeでRemote-SSHできないときの対処法

Last updated at Posted at 2020-12-28

Windows標準のSSHクライアントとVisual Studio CodeのRemote-SSHの組合せハマった時のメモ。

結論としては、Windows標準のssh.exeを使わずに、Windows版gitに付属のssh.exeを使ったら解決した。

環境

  • ホスト
    • OS: Windows 10
    • SSHクライアント: Windows 10 標準 (OpenSSH_for_Windows_7.7p1, LibreSSL 2.6.5)
  • Remote
    • OS: Ubuntu 18.04
    • SSHサーバ:OpenSSH Server

現象

VSCodeからRemote接続すると、RemoteとのSSH接続までは成功する。その後、Remoteのフォルダを開こうとするとフリーズ。
しばらくするとSSHが切断され、再接続を求められる。これの繰り返し。

対策

VSCodeが使うSSHクライアントを、Windows版gitに付属のssh.exeに変更する。
具体的にはVSCodeのsettings.jsonを開いて下記のエントリを追加する。

"remote.SSH.path": "C:\\Program Files\\Git\\usr\\bin\\ssh.exe"

Windows版gitが未インストールの場合には先にインストールしておくこと。

補足

Window標準のSSHクライアントのバージョン

PS C:\Windows\System32\OpenSSH> ssh -V
OpenSSH_for_Windows_7.7p1, LibreSSL 2.6.5

Windows版gitのSSHクライアントのバージョン

PS C:\Program Files\Git\usr\bin> & 'C:\Program Files\Git\usr\bin\ssh.exe' -V
OpenSSH_8.3p1, OpenSSL 1.1.1g  21 Apr 2020
2
0
2

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
2
0