Just do IT

思うは招く

Vagrant + VSCode + Remote Development でリモートサーバーを編集したい

やりたいこと

  • Vagrantを使った仮想環境にVSCodeからアクセスしてファイルをいじりたい

環境

Remote Development プラグインVSCodeに入れよう

Remote Development

k-koh.hatenablog.com

設定ファイルを書こう

vagrantコマンドが使えるディレクティブへ移動。 以下を叩く

vagrant ssh-config

Host default
  HostName IPアドレス
  User vagrant
  Port ポート番号
  UserKnownHostsFile /dev/null
  StrictHostKeyChecking no
  PasswordAuthentication no
  IdentityFile /Users/<username>/vagrant/debian_contrib-buster64/.vagrant/machines/default/virtualbox/private_key
  IdentitiesOnly yes
  LogLevel FATAL

表示された内容をすべてコピーし、~/.ssh/configにペーストするだけ。

# 面倒ならこのコマンドで一発
vagrant ssh-config >> ~/.ssh/config

これで設定は終わり! Remote Development をすでに利用してるなら、コマンド一発で準備が終わってしまうという、泣けるほど簡単な設定。

参考:VagrantでVScodeのRemote Developmentを使おう! - Qiita