iTranslated by AI
Access Multipass Ubuntu 20.04 via VS Code Remote-SSH on macOS
Introduction
↑ Access the environment created above using the Visual Studio Code Remote-SSH plugin.
Environment
- Visual Studio Code 1.64.1 [1]
- Remote-SSH v0.70.0
- Japanese Language Pack for Visual Studio Code
Remote-SSH
A plugin for connecting to Multipass Ubuntu from within VS Code.
Installing the Plugin

- Select Extensions
- Enter "REMOTE SSH" in the search box

3. Click "Remote - SSH"
4. Press the "Install" button
Connecting to Multipass Ubuntu 20.04

- Select Remote Explorer
- Right-click "docker-vm.local" [2] (The connection menu will be displayed)

Select "Connect to Host in Current Window".

If "SSH: docker-vm.local" is displayed in the bottom left, the connection is successful.
*If a warning appears

When recreating a virtual machine (VM), a "Warning: the ECDSA host key for ..." warning may appear.
It will stop appearing if you delete the lines indicated by the numbers after the colon in the file underlined in red (lines 6 and 7 of ~/.ssh/known_hosts).
Disconnecting from Multipass Ubuntu 20.04

- Click "SSH: docker-vm.local" in the bottom left
- Click "Close Remote Connection" from the menu
Usage
Basically, it can be used in the same way as using VS Code locally.
Connection Settings
A folder named "~/.vscode-server" is created in Multipass Ubuntu 20.04.
Configuration files are created and plugins are installed under "~/.vscode-server".
Terminal
Access Ubuntu from VS Code without starting the Mac terminal.

Click "Terminal" -> "New Terminal" from the menu.

A terminal opens within VS Code.
You can use the shell from within VS Code without having to manually log into Multipass.
Opening folders in Ubuntu 20.04

- Select Explorer
- Click "Open Folder"

Click "localstack-0.13.0" in the "Open File or Folder" dialog.

Press the "OK" button.

Press the "Yes, I trust the authors. Trust folder and enable all features" button. [3]

The file list is displayed just like in normal use.
Clicking README.md displays the contents of the file.
Docker plugin
Enables Docker operations from within VS Code.

- Enter "docker" in the extensions search box
- Press the "Install" button next to the Docker plugin.

The Docker icon is added to the sidebar.

Running Docker information is displayed. [4]
Also, you can browse information within images.

Right-clicking a running Docker container displays a menu.
You can execute various functions.
Port Forwarding
Add port forwarding settings to allow access from the Mac side to LocalStack running via docker-compose.

There is a "Ports" tab in the same area as the terminal.
- Select the Ports tab
- Press the "Forward a Port" button

Click "Port number or address"

Enter "4566" and press the Enter (return) key.

Confirm that the setting has been added.

Access LocalStack from the Mac terminal using the curl command.
% curl -s http://localhost:4566/health | jq
{
"features": {
"initScripts": "initialized"
},
"services": {
"acm": "available",
"apigateway": "available",
"cloudformation": "available",
"cloudwatch": "available",
... (remainder omitted) ...
Reference Sites
- Portable Mode in Visual Studio Code
- SSH Connection in VSCode | SRIA BLOG - Web and Smartphone App Development in Sendai, Miyagi
- Developing on Remote Machines using SSH and Visual Studio Code
- How to resolve the "Warning: the ECDSA host key for ..." error during SSH connection | Show46
Discussion