Setting Up an Ubuntu Dev Environment with Multipass and VS Code Remote-SSH

Why Develop in Ubuntu While Keeping Your Desktop OS?

If you’re working on projects in embedded development, robotics, or cybersecurity, you know that Ubuntu is often the go-to operating system for many open-source tools and libraries. Howeve…


This content originally appeared on DEV Community and was authored by Daniel Puig Gerarde

Why Develop in Ubuntu While Keeping Your Desktop OS?

If you’re working on projects in embedded development, robotics, or cybersecurity, you know that Ubuntu is often the go-to operating system for many open-source tools and libraries. However, many of us prefer to stick with our native desktop operating system (macOS, Windows) for everyday use. Setting up a dedicated Ubuntu development environment that doesn't disrupt your daily workflow can be easily achieved with Multipass, a tool for running lightweight Ubuntu VMs on your computer. Here’s how you can set up a productive, versatile Ubuntu environment for development while still using your primary OS.

What You'll Need

  • Multipass: A tool for managing Ubuntu VMs.
  • Visual Studio Code (VS Code): A powerful, extensible code editor.
  • VS Code Remote - SSH Extension: To connect seamlessly from your host OS to your Ubuntu VM.
  • Basic Understanding of the Command Line: To install tools and manage your VM.

Step 1: Install Multipass

  1. Download and Install Multipass
    Multipass makes creating and managing Ubuntu VMs extremely simple. Download it from the official website and follow the installation instructions for your OS.

  2. Launch Your Ubuntu VM
    Once installed, open your terminal (Command Prompt on Windows, Terminal on macOS or Linux), and use this command to create an Ubuntu instance:

$ multipass launch --name ubuntu-dev --mem 4G --disk 20G

Another way is to launch the VM with the default values ​​and then you can edit the settings

$ multipass launch --name ubuntu-dev

$ multipass stop ubuntu-dev

$ multipass set local.ubuntu-dev.memory=4G

$ multipass set local.ubuntu-dev.disk=20G

$ multipass start ubuntu-dev
  1. Verify and Access Your VM To confirm that your instance is running, use:
$ multipass list

Once it's listed as "Running," you can connect to it:

$ multipass shell ubuntu-dev

# Inside ubuntu-dev 
$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 22.04.5 LTS
Release:        22.04
Codename:       jammy

Step 2: Set Up VS Code with Remote-SSH

One of the most effective ways to code and debug on your Ubuntu VM without leaving your native OS is by using VS Code with the Remote - SSH extension.

  1. Install Visual Studio Code
    If you don’t have it yet, download VS Code for your OS.

  2. Install the Remote - SSH Extension
    Open VS Code, go to the Extensions view, and install Remote - SSH. Or using the command in a terminal:

$ code --install-extension ms-vscode-remote.vscode-remote-extensionpack
  1. Configure SSH to Connect to Your VM Add your SSH key to the VM How to Use ssh-keygen to Generate a New SSH Key?
$ multipass exec ubuntu-dev -- bash -c "echo `cat ~/.ssh/<key>.pub` >> ~/.ssh/authorized_keys"

Also retrieve the key from GitHub:

multipass exec ubuntu-dev -- bash -c “curl https://github.com/<username>.keys | tee -a ~/.ssh/authorized_keys”
  1. Connect to Your VM in VS Code In VS Code, open the Command Palette (Ctrl+Shift+P or Cmd+Shift+P on macOS) and select Remote-SSH: Connect to Host. Choose ubuntu-dev from the list. Or using the command in a terminal:
$ code --folder-uri vscode-remote://ssh-remote+ubuntu@<vm-ip>/home/ubuntu

You are now remotely editing and debugging code on your Ubuntu VM through VS Code!

  1. Mount Local Folder A good idea is to mount a local folder
$ multipass mount /some/local/path ubuntu-dev:/some/remote/path

Step 3: Set Up Your Development Tools in Ubuntu

  • Update and Install Essentials First, make sure your system is up-to-date:
$ sudo apt update && sudo apt upgrade -y

Then, install any essentials you might need, such as Git and build-essential:

$ sudo apt install -y git build-essential
  • Install Specific Tools for Embedded Development, Robotics, or Cybersecurity For embedded development, robotics, or cybersecurity, install domain-specific tools:
# Example packages for embedded dev, robotics, and cybersecurity
$ sudo apt install -y gcc-arm-none-eabi gdb openocd ros-noetic-desktop wireshark nmap

Step 4: Set Up for Embedded Development, Robotics, and Cybersecurity

Embedded Development: Install gcc, gdb, and openocd to compile, debug, and program microcontrollers. These tools make Ubuntu ideal for ARM and RISC-V development workflows.

Robotics: Installing ROS (Robot Operating System) on Ubuntu is straightforward and fully supported. ROS Noetic, the latest version, offers a rich ecosystem for simulation, control, and robot software development.

$ sudo apt install ros-noetic-desktop-full

Cybersecurity: Ubuntu provides an ideal platform for cybersecurity research, with support for tools like Wireshark, Nmap, Metasploit, and others. Installing them is a simple command away:

$ sudo apt install wireshark nmap metasploit-framework

Step 5: Maintenance and Snapshot Management

Multipass makes it easy to take snapshots, which allow you to create backups of your development environment. This is especially useful if you want to test potentially disruptive software.

To take a snapshot:

$ multipass snapshot ubuntu-dev

To restore a snapshot:

$ multipass restore ubuntu-dev

These commands make it easy to experiment with new tools without risking your setup.

Why This Setup Works

By isolating your development environment in Ubuntu, you gain access to the rich Linux ecosystem, which includes tools specifically tailored to robotics, embedded systems, and cybersecurity, while maintaining your main OS for everyday tasks. This approach offers flexibility, reduces clutter on your host OS, and provides an ideal testing ground for domain-specific projects.

Whether you’re building an IoT solution, exploring autonomous vehicle software, or working on network security, this setup offers a powerful and versatile development workflow.


This content originally appeared on DEV Community and was authored by Daniel Puig Gerarde


Print Share Comment Cite Upload Translate Updates
APA

Daniel Puig Gerarde | Sciencx (2024-10-28T02:19:28+00:00) Setting Up an Ubuntu Dev Environment with Multipass and VS Code Remote-SSH. Retrieved from https://www.scien.cx/2024/10/28/setting-up-an-ubuntu-dev-environment-with-multipass-and-vs-code-remote-ssh/

MLA
" » Setting Up an Ubuntu Dev Environment with Multipass and VS Code Remote-SSH." Daniel Puig Gerarde | Sciencx - Monday October 28, 2024, https://www.scien.cx/2024/10/28/setting-up-an-ubuntu-dev-environment-with-multipass-and-vs-code-remote-ssh/
HARVARD
Daniel Puig Gerarde | Sciencx Monday October 28, 2024 » Setting Up an Ubuntu Dev Environment with Multipass and VS Code Remote-SSH., viewed ,<https://www.scien.cx/2024/10/28/setting-up-an-ubuntu-dev-environment-with-multipass-and-vs-code-remote-ssh/>
VANCOUVER
Daniel Puig Gerarde | Sciencx - » Setting Up an Ubuntu Dev Environment with Multipass and VS Code Remote-SSH. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2024/10/28/setting-up-an-ubuntu-dev-environment-with-multipass-and-vs-code-remote-ssh/
CHICAGO
" » Setting Up an Ubuntu Dev Environment with Multipass and VS Code Remote-SSH." Daniel Puig Gerarde | Sciencx - Accessed . https://www.scien.cx/2024/10/28/setting-up-an-ubuntu-dev-environment-with-multipass-and-vs-code-remote-ssh/
IEEE
" » Setting Up an Ubuntu Dev Environment with Multipass and VS Code Remote-SSH." Daniel Puig Gerarde | Sciencx [Online]. Available: https://www.scien.cx/2024/10/28/setting-up-an-ubuntu-dev-environment-with-multipass-and-vs-code-remote-ssh/. [Accessed: ]
rf:citation
» Setting Up an Ubuntu Dev Environment with Multipass and VS Code Remote-SSH | Daniel Puig Gerarde | Sciencx | https://www.scien.cx/2024/10/28/setting-up-an-ubuntu-dev-environment-with-multipass-and-vs-code-remote-ssh/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.