Skip to main content
In this guide, we demonstrate how to connect to a Linux VM running on VirtualBox using different network configurations. While the demo covers both Windows and Mac environments, the fundamental concepts remain the same. The key difference lies in the network configuration: Windows uses a bridged adapter that assigns an external IP address, whereas Mac uses the default NAT configuration. On the left, you can see the Mac configuration, and on the right, the Windows configuration. In the Windows deployment, a bridged adapter allows the VM to join the external network, obtaining an IP address from it. This enables SSH connectivity as if the VM were another physical host on your network.
The image shows network settings for virtual machines on Mac and Windows, highlighting adapter configurations in virtualization software.
When using NAT, as on Mac, the VM does not receive an IP address on the external network. Instead, SSH access requires you to configure port forwarding. Both network configurations—bridged and NAT—are available on Windows and Mac, offering different connectivity options depending on your needs.

Connecting on Mac

When you power on the system, if the console appears too small, adjust the scale from the View menu to 300%. A welcome screen and wizard may appear; simply complete them and close the wizard.

Step 1: Check the IP Address

Open the terminal from the applications menu and check the VM’s IP address:
The VM will display an IP address of 10.0.2.15. This is a private internal IP assigned by the NAT router, meaning it is not accessible externally from the host. Do not attempt to ping or SSH into this IP directly from the host. Even if multiple VMs use NAT (resulting in the same IP), they remain isolated from one another. However, with a functioning internet connection, all VMs can access external sites. Verify connectivity by pinging an external website:
The VM’s IP (10.0.2.15) is assigned for internal communication by the NAT router and is not reachable from your host directly.

Step 2: Verify SSH Service

Before attempting to SSH, ensure that the SSH service is running on the VM:
Since the NAT configuration does not provide an externally reachable IP, port forwarding is required to enable SSH access.

Setting Up Port Forwarding

  1. Open the VM Settings: Navigate to the Networking section.
  2. Select Port Forwarding: Choose the Port Forwarding option to add a new rule.
  3. Configure the Port Forwarding Rule:
    • The VM’s SSH service listens on port 22.
    • Since the host may also use port 22, choose an alternative host port (e.g., 2222) to forward to port 22 on the VM.
    • Name the rule (e.g., “SSH port”).
Once configured, you can SSH into the VM using the loopback IP address (127.0.0.1) and the designated host port:
The image shows a virtual machine network settings window, configuring SSH with TCP protocol, host port 2222, and guest port 22, on a CentOS VM.

Step 3: SSH into the VM

To connect, execute the following command (adjust the username as needed):
Once connected, you can run commands on the VM. For example, inspect the OS release files to confirm the system is running CentOS 7:
The displayed OS release details confirm that you have connected to the correct CentOS 7 system.
That concludes this demo. Enjoy smooth SSH connectivity to your Linux VM on Mac!

Watch Video