0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Azure VMへVScodeでSSHする方法

Posted at

Azure VMへ VS Code で SSH 接続する方法

Azure の Linux VM に VS Code から SSH で接続する手順を備忘録的にまとめます。


🎯 前提条件

  • VS Code に拡張機能 Remote - SSH がインストールされている
  • Azure 上に Linux VM が構築されている
  • SSH 鍵認証で接続する(パスワード接続ではない)

⚙️ 手順

① SSH 鍵を配置する

ローカルPCの以下のディレクトリに秘密鍵(.pem など)を保存します。

C:\Users\<ユーザー名>\.ssh\

② SSH 設定ファイル(config)を作成・編集する

C:\Users\<ユーザー名>\.ssh\config を開き、以下のように記述します。

Host vm-test
    HostName 10.xx.xx.xx
    User test
    IdentityFile C:\Users\<ユーザー名>\.ssh\<秘密鍵ファイル名>
    IdentitiesOnly yes

各項目の意味

項目 説明
Host VS Code などで指定する接続名(任意)
HostName VM のパブリック IP またはプライベート IP
User Azure VM 作成時に設定したユーザー名(例: azureuserなど)
IdentityFile 秘密鍵(.pem)のパス
IdentitiesOnly yes 指定した鍵だけを使うように制限(複数鍵を持つ人は必須)

③ VS Code で接続する

  1. VS Code のコマンドパレット(Ctrl + Shift + P)を開く
  2. Remote-SSH: Connect to Host... を選択
  3. 一覧から先ほど設定した vm-test を選択

初回接続時は VS Code がリモートサーバーに必要なモジュールを自動でインストールします。


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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?