How to Enable SSH in VirtualBox

Secure Shell (SSH) allows you to remotely access and manage a virtual machine from another system or from the host computer itself. When running a Linux or server-based guest operating system inside VirtualBox, enabling SSH makes it easier to manage the VM through a terminal instead of using the graphical interface. This is especially useful for development, server testing, and network configuration tasks.

In Oracle VirtualBox, enabling SSH involves two main steps: installing and enabling the SSH service inside the guest operating system, and configuring VirtualBox network settings to allow remote access. Proper configuration ensures secure and stable connectivity between your host and the virtual machine.

This guide explains how to enable SSH in VirtualBox on Windows 11 using structured steps.

How to Enable SSH in VirtualBox

Follow the steps below carefully to enable SSH access to your virtual machine.

1. Install OpenSSH Server in the Guest OS

First, you must install the SSH server inside the guest operating system.

  1. Start your virtual machine in Oracle VM VirtualBox.
  2. Log in to your Linux guest system.
  3. Open the terminal.
  4. Run the following command to update packages:sudo apt update
  5. Install the OpenSSH server using:sudo apt install openssh-server
  6. Wait for the installation to complete.

This installs the SSH service required for remote access.

2. Start and Enable the SSH Service

After installation, ensure the SSH service is running.

  1. In the terminal, type:sudo systemctl start ssh
  2. To enable SSH to start automatically on boot, type:sudo systemctl enable ssh
  3. Verify the service status with:sudo systemctl status ssh

If the status shows “active (running),” SSH is properly enabled.

3. Configure Network Settings in VirtualBox

To allow SSH access from the host system, configure the VM’s network adapter.

  1. Power off the virtual machine.
  2. In VirtualBox Manager, select your VM.
  3. Click Settings.
  4. Go to the Network section.
  5. Choose one of the following adapter types:
    • Bridged Adapter for direct access on the same network.
    • NAT with port forwarding for host-only access.

For NAT configuration:

  1. Click Advanced.
  2. Select Port Forwarding.
  3. Add a new rule with:
    • Host Port: 2222
    • Guest Port: 22
  4. Click OK to save.

Restart the virtual machine after saving network settings.

4. Find the Guest IP Address

If using Bridged Adapter, you need the guest’s IP address.

  1. Start the virtual machine.
  2. Open the terminal.
  3. Run:ip a
  4. Locate the IP address assigned to your network interface.

Note the IP address for SSH connection.

5. Connect to the Virtual Machine via SSH

Now connect from your Windows 11 host system.

  1. Press Windows + S, type cmd, and open Command Prompt.
  2. If using NAT with port forwarding, type:ssh username@127.0.0.1 -p 2222
  3. If using Bridged Adapter, type:ssh username@guest-ip-address
  4. Enter your password when prompted.

You should now have terminal access to your virtual machine via SSH.

6. Allow SSH Through Firewall (If Needed)

If connection fails, ensure the guest firewall allows SSH.

  1. In the guest OS terminal, run:sudo ufw allow ssh
  2. Enable firewall if not already active:sudo ufw enable
  3. Retry the SSH connection.

Allowing SSH ensures proper communication through port 22.

Conclusion

Enabling SSH in VirtualBox involves installing the OpenSSH server in the guest operating system, starting the SSH service, configuring network settings properly, and connecting from the host system. Whether using NAT with port forwarding or a Bridged Adapter, correct network configuration is essential for successful remote access.

Posted by Raj Bepari

I’m a digital content creator passionate about everything tech.