0
1

More than 1 year has passed since last update.

Visual Studio Code の Remote SSH でリモートマシンをコマンドライン指定で開く

Last updated at Posted at 2021-02-07

Visual Studio Code の Remote SSH でリモートマシンをコマンドライン指定で開く

Visual Studio Code の Remote SSH で Linux 上のファイルを直接編集する の記事でリモートマシンにあるファルダ/ファイルを編集する方法を紹介しました。

コマンドライン指定で直接 リモートマシンおよび、リモートマシン上のフォルダ/ファイルを開くことができるので紹介します。

前提知識

https://qiita.com/m-tmatma/items/f3cc666c2e667adab784 で記載しましたが、

C:\Users\winuser\.ssh\config に以下のような設定をしているはずです。

# Read more about SSH config files: https://linux.die.net/man/5/ssh_config
Host alias
    HostName hostname
    User user
    IdentityFile C:\Users\winuser\.ssh\id_rsa

この設定の Host alias の部分で指定している alias の部分が Vscode 状で見えるホスト名であり、この記事で指定する <マシン名> です。

方法1 (フォルダ/ファイルを指定せず、リモートマシンに接続するだけ)

code --remote ssh-remote+<マシン名> <パス>

方法2 (フォルダ/ファイルを指定して、リモートマシンのファルダ/ファイルを開く)

code --remote ssh-remote+<マシン名> <パス>

例1: マシン名 testmachine

code --remote ssh-remote+testmachine

例2: マシン名 testmachine パス /home/user/

code --remote ssh-remote+testmachine /home/user/

参考URL

https://github.com/microsoft/vscode-remote-release/issues/585
https://github.com/microsoft/vscode-remote-release/issues/585#issuecomment-536580102

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