DEV Community

R. Quazi
R. Quazi

Posted on

Install Ubuntu 24.04 or Any Linux Flavor on Windows 11 and Access It via SSH Using Tailscale Private IP

1 Introduction

In today's tech-driven world, many professionals and hobbyists need to work across both Windows and Linux environments. Whether you're a developer or a small business owner relying on Windows for daily tasks but needing Linux-based applications, the challenge is to efficiently run Linux applications without disrupting your primary Windows setup.

Linux environments are often preferred for running applications like Nginx, Apache, Jenkins, Docker, Kubernetes, and MongoDB, as many software tools are optimized for Linux. However, since most computers come with Windows pre-installed, finding an efficient way to run Linux applications is important.

Image description

Image Credit : Ubuntu

1.1 Common Methods to Run Linux on Windows:

  1. Dual Boot: Windows + Linux. This method requires rebooting to switch between operating systems, which can be inconvenient and consumes more resources.

  2. Cloud VM/VPS: Effective but potentially costly. Even when not in active use, you might incur charges for storage and uptime/IP etc.

  3. VirtualBox: Provides a portable solution without altering the host system directly. But, it requires allocating CPU cores RAM and storage, which can impact system performance.

  4. LXC/LXD Containers: Containers share the host’s kernel but have their own filesystem, processes, and network stack. They may not always integrate seamlessly with host applications.

  5. Docker Containers: Similar to LXC containers, Docker containers share the host’s kernel and might be restrictive in GUI support and file system access.

Each of these methods has its trade-offs. Dual booting requires frequent reboots, virtual machines can consume significant resources, and containers may be limiting in terms of file access and GUI support.

To find a balance between efficiency, convenience, and functionality, you need a solution that bridges the gap between Windows and Linux environments.


2 WSL (Windows Subsystem for Linux)

WSL is a compatibility layer that allows you to run a Linux distribution directly on Windows. It provides a Linux-like environment within Windows, making it ideal for developers who need Linux tools and utilities. WSL supports various development, scripting, and testing tasks and can even run DevOps tools like Kubernetes , docker and jenkins etc.

"To master technology, we must learn to integrate it, not just use it in isolation."

2.1 WSL Advantages

  • Direct Integration: Seamlessly interacts with the Windows filesystem.
  • Software Compatibility: Works well with Windows software (e.g., Docker Desktop , VS code).
  • Full Linux Kernel: Utilizes a complete Linux kernel in WSL 2.
  • Interoperability: Facilitates interaction between Windows and Linux applications.
  • Convenience: Easier setup and use compared to dual boot or traditional VMs.
  • Developer-Friendly: Streamlined for development tasks.
  • Easier Maintenance: Simpler to manage than dual boot systems or VMs.

2.2 WSL Limitations

  • Performance: Not as performant as a native Linux installation.
  • GUI Support: Limited support for graphical applications.
  • Kernel Limitations: Not suitable for all use cases, especially those requiring specific kernel modules or low-level hardware access.

3 Installation

3.1 System Requirements

Before installing WSL, ensure your system meets the following requirements:

  • Enable Virtualization in your BIOS settings.
  • Windows 10 version 2004 or higher (Build 19041 or higher)
    • For x64 systems: Version 1903 or later, Build 18362.1049 or later.
    • For ARM64 systems: Version 2004 or later, Build 19041 or later.
  • Windows 11 is fully compatible.
  • Minimum 4 GB RAM.

3.2 Opening PowerShell as Administrator

To install WSL, you need to open PowerShell with administrative privileges. Follow one of these methods:

3.2.1 Option 1: Using the Start Menu

  1. Press the Windows key or click the Start menu.
  2. Type PowerShell in the search bar.
  3. Right-click Windows PowerShell from the search results.
  4. Select Run as administrator.

Image description

3.2.2 Option 2: Using the Run Dialog

  1. Press Windows Key + R to open the Run dialog.
  2. Type powershell in the text box.
  3. Press Ctrl + Shift + Enter to run PowerShell as an administrator. Avoid pressing Enter alone, as this will open PowerShell in normal user mode.

Image description

3.3 Enabling WSL and Installing a Linux Distribution

3.3.1 Enable the Required Features

First, enable the "Windows Subsystem for Linux" feature and the Virtual Machine Platform feature:

Enable "Windows Subsystem for Linux"



dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart


Enter fullscreen mode Exit fullscreen mode

Output:



Deployment Image Servicing and Management tool
Version: 10.0.22621.2792

Image Version: 10.0.22631.3880

Enabling feature(s)
[==========================100.0%==========================]
The operation completed successfully.


Enter fullscreen mode Exit fullscreen mode

Enable "Virtual Machine Platform"



dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart


Enter fullscreen mode Exit fullscreen mode

Output:



Deployment Image Servicing and Management tool
Version: 10.0.22621.2792

Image Version: 10.0.22631.3880

Enabling feature(s)
[==========================100.0%==========================]
The operation completed successfully.


Enter fullscreen mode Exit fullscreen mode

After running these commands, restart your computer to apply the changes.

3.3.2 Install the Linux Kernel Update Package

To download and install the latest Linux kernel update package:

  • For x64: ```PowerShell

wsl.exe --install


- For ARM 64 :
Download the package : https://wslstorestorage.blob.core.windows.net/wslblob/wsl_update_arm64.msi

Double click to install the WSL.

> [!NOTE]
> > If you dont know the type of system you are using you can run this command : ``systeminfo | find "System Type"``
> > Output : `System Type:               x64-based PC`
> 
> 


Output:
Enter fullscreen mode Exit fullscreen mode

...
...
...
Launching Ubuntu...
Installing, this may take a few minutes...
Please create a default UNIX user account. The username does not need to match your Windows username.
For more information visit: https://aka.ms/wslusers
Enter new UNIX username:


### 3.3.3    Set WSL Version 2 as the Default

Ensure that WSL version 2 is set as the default version:
```PowerShell


wsl --set-default-version 2


Enter fullscreen mode Exit fullscreen mode

Output:



For information on key differences with WSL 2 please visit https://aka.ms/wsl2
The operation completed successfully.


Enter fullscreen mode Exit fullscreen mode

3.3.4 Install Your Preferred Linux Distribution

Install your favorite Linux distribution. For example, to install Ubuntu 24.04:



wsl --install -d Ubuntu-24.04


Enter fullscreen mode Exit fullscreen mode

Or you can install any distro of your choice :

Linux Distribution WSL Installation Command
Ubuntu 18.04 LTS wsl --install -d Ubuntu-18.04
Ubuntu 20.04 LTS wsl --install -d Ubuntu-20.04
Ubuntu 22.04 LTS wsl --install -d Ubuntu-22.04
openSUSE Leap 15.1 wsl --install -d openSUSE-Leap-15.1
SUSE Linux Enterprise Server 12 SP5 wsl --install -d SLES-12-SP5
SUSE Linux Enterprise Server 15 SP1 wsl --install -d SLES-15-SP1
Kali Linux wsl --install -d Kali-Linux
Debian GNU/Linux wsl --install -d Debian
Fedora Remix for WSL wsl --install -d Fedora-Remix-for-WSL
Pengwin wsl --install -d Pengwin
Pengwin Enterprise wsl --install -d WLinux-Enterprise
Alpine WSL wsl --install -d Alpine
Raft (Free Trial) wsl --install -d Raft
AlmaLinux wsl --install -d AlmaLinux

3.3.5 Set Up Your Linux Distribution

Once the installation is complete, open your Linux distribution (e.g., Ubuntu 24.04) and create a username and password when prompted.

3.3.6 Verify Installation and Check WSL Version

To check the installed distributions and their WSL versions, use:



wsl -l -v


Enter fullscreen mode Exit fullscreen mode

Output:



  NAME            STATE           VERSION
* Ubuntu-24.04    Stopped         2
  Ubuntu          Stopped         2


Enter fullscreen mode Exit fullscreen mode

3.3.7 Launch Your Linux Distribution

You can launch Ubuntu (or any installed Linux distribution) using either of the following commands:

Using the distribution executable:



ubuntu2404.exe


Enter fullscreen mode Exit fullscreen mode

Using WSL command:



wsl


Enter fullscreen mode Exit fullscreen mode

4 Tailscale

Tailscale is a modern VPN service that simplifies connecting devices and applications over a secure network. It leverages the WireGuard protocol to create a peer-to-peer mesh network, known as TailNet, which allows devices within the same private network to communicate directly. This is different from traditional VPNs, which route all traffic through a central gateway.

Tailscale can be used for various purposes, including:

  • SSH Access: Securely connect to remote machines.
  • File Access and Sharing: Access and share files across devices.
  • Private Website Access: Reach privately hosted websites.
  • Database and Kubernetes Clusters: Connect to databases and Kubernetes clusters securely. ## 4.1 Key Differences from Traditional VPNs

Traditional VPNs create a central tunnel for all network traffic, routing it through a single gateway. In contrast, Tailscale establishes a peer-to-peer or point-to-point mesh network, which they refer to as TailNet, enabling direct communication between devices.

4.2 Setting Up Tailscale

4.2.1 Sign Up and Access the Admin Dashboard

  1. Sign Up: Create an account at Tailscale.
  2. Admin Dashboard: After signing up, you will be directed to the Tailscale Admin Dashboard.

Image description

4.2.2 Install Tailscale on WSL

  1. Open your WSL terminal and run: ```bash

curl -fsSL https://tailscale.com/install.sh | sh

2. Check the status of the Tailscale service:
   ```bash


   sudo systemctl status tailscaled


Enter fullscreen mode Exit fullscreen mode
  1. Enable and start the Tailscale service: ```bash

sudo systemctl enable tailscaled
sudo systemctl start tailscaled


### 4.2.3    Install Tailscale on Windows
1. Download the Tailscale installer for Windows from [here](https://pkgs.tailscale.com/stable/tailscale-setup-latest.exe).
2. Once Installed login to tailscale.

### 4.2.4    Configure Tailscale
1. **Generate an Auth Key**:
   - Return to the Tailscale Admin Dashboard.
   - Navigate to **Settings** to generate an authentication key.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2ywgb6cwtwbog9p15dbk.png)






2. **Authenticate and Connect**:
   - Return to your WSL terminal.
   - Run the following command to authenticate and connect:
     ```bash


     sudo tailscale up --auth-key=YOUR_AUTH_KEY --ssh


Enter fullscreen mode Exit fullscreen mode

Replace YOUR_AUTH_KEY with the key you generated.

Congratulations! Your WSL is now configured for remote SSH access over a private IP. Both your Windows machine and the WSL instance should be connected to Tailscale to access resources or applications and to perform SSH.

4.2.5 SSH Using Tailscale Browser-Based Access

  1. Access Tailscale Admin Portal:
    • Go to the Tailscale Admin Portal.
    • Select the machine you want to SSH into and choose the option to SSH into the machine.

Image description

  1. Select User:
    • Choose the user you want to log in as.

Image description

  1. Confirm Identity:
    • Confirm your identity by logging in to Tailscale.

You are now connected to WSL through your browser.

Image description

Congratulations! You have successfully set up Ubuntu 24.04 on Windows 11 using WSL and configured it for secure SSH access via Tailscale. This setup allows you to leverage the power of Linux applications seamlessly within your Windows environment while ensuring secure, private connectivity from anywhere and using any device.


If you found this guide helpful and have any questions or feedback, feel free to reach out. For more insights on technology and to stay updated with my latest content, connect with me on LinkedIn and you can support open source community by buying a coffee here.

Connect with me : hi@plexio.cloud

Thank you for reading!


References:

Top comments (0)