--- lang: ja-jp breaks: true --- # Azure Visual Studio Code から プライベートキーファイルを指定したSSH接続 2021-05-06 > https://code.visualstudio.com/docs/remote/ssh-tutorial ## 環境 #### Visual Studio Code ![](https://i.imgur.com/r06QxM6.png) #### Remote - SSH ![](https://i.imgur.com/DSE4xv6.png) #### Azure Virtual Machines ```shell= $ uname -a Linux XXXXXXXX 5.4.0-1046-azure #48~18.04.1-Ubuntu SMP Tue Apr 13 19:41:38 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux ``` ## コマンドパレットより、「Remote:SSH Config File」を設定する。 ![](https://i.imgur.com/TDph9vS.png) ※パスの区切り文字を"\\\\"として設定すること。 ![](https://i.imgur.com/nSn5nDl.png) ## Azureからダウンロードしたプライベートキーファイルを、「C:\\Users\\[ユーザ名]\\.ssh\\~」に格納する。 ※「puttygen.exe」で変換したファイルはフォーマットが不正とのエラーが出るので、変換する前のファイルを使用する事。 ## プライベートキーファイルの権限を変更する。 ※Visual Studio Codeを利用するユーザにフルコントロールを与え、それ以外のユーザは全て削除すること。余計なユーザが残っているとエラーとなる。 ![](https://i.imgur.com/u0yz6aU.png) ## ~\\.ssh\\config の設定 ![](https://i.imgur.com/5fQExqy.png) ※「C:\\Users\\[ユーザ名]\\.ssh\\config」を選択する。 ![](https://i.imgur.com/hrfF08E.png) ```shell= # Read more about SSH config files: https://linux.die.net/man/5/ssh_config Host AzureDbServer HostName [ip_address] User [ssh username] IdentityFile "C:\Users\[username]\.ssh\DBServer_key.pem" ``` ## 以上の設定でSSH接続が可能となる。 ![](https://i.imgur.com/Yjhelq6.png) ###### tags: `Azure` `Visual Studio Code` `SSH` `Azure Virtual Machines`