Need help?

Our experts have had an average response time of 11.7 minutes in August 2021 to fix urgent issues.

We will keep your servers stable, secure, and fast at all times for one fixed price.

How to enable access to VirtualBox via SSH NAT ?

by | Mar 20, 2019

VirtualBox allows to create different guest virtual machines on top of the same host. And, it provides isolation from the host too.

But, what if you need to access the guest machine via SSH?

That’s where Network Address Translation (NAT) helps. It allows SSH access even to the virtual servers.

At Bobcares, we often get requests from customers to enable VirtualBox SSH NAT settings as part of our Infrastructure Management Services.

Today, we’ll see how our Dedicated Engineers setup SSH via NAT in Virtualbox and solve common issues with it.


How VirtualBox NAT helps?

Let’s now take a look on the need for having special settings to SSH to the guest server.

VirtualBox support Network Address Translation aka NAT. NAT simply maps an address to another.

Usually, by enabling NAT networking for any guest server, VirtualBox automatically performs IP address translation between the guest VM and host’s network. And, there is no need to configure anything on the host machine or on the local network in guest. However, this makes guest VM not reachable or visible from external networks. Thus, it creates problems when you want to access the guest VM directly.

Fortunately, by enabling port forwarding for port 22, we can SSH to the guest machine from the host.


Steps to enable SSH on VirtualBox

Now, let’s see how our Dedicated Engineers setup port forwarding for VirtualBox NAT. There are options to do this either from the GUI or from the command line. We’ll check both methods here.


1. Port forwarding from GUI

Firstly, let’s see how to do this from the VirtualBox web interface.

On VirtualBox, to allow SSH access, we need to edit the network settings of the guest VM.

For this, we first choose the guest VM, then open “Settings” >> “Network” >> “Advanced” section. This will show additional network adapter options. Then, we click on “Port Forwarding” button.

Here, we add a new port forwarding rule. It will contain a name for the rule, protocol, host IP, port and guest IP and port.

For example, to enable SSH access on a guest machine with IP on port 2522, our Support Engineers set up the rule from the panel as


When we power on the guest VM, it will automatically enable this rule. However, to confirm that port 2522 is listening, we check using the netstat command.

Now, we can SSH to the guest VM using

ssh -p 2522 <login>@

Here, the SSH login request sent to will automatically be translated into by VirtualBox. Thus, we can now SSH to the guest VM.


2. Port forwarding from command line

Similarly, we can add port forwarding from the command line too. Let’s check on how to do this too.

Here, we make use of the VirtualBox command-line management interface called VBoxManage.

To create a port forwarding rule for guest VM named “Centos” with IP address and SSH port 22, mapped to local host at port 2522, our Dedicated Engineers use the command:

VBoxManage modifyvm "Centos" --natpf1 "SSH,tcp,,2522,,22"

Here, the name of the rule should be set as unique.

After creating the rule, we verify it using

VBoxManage showvminfo "Centos" | grep NIC

And, this will show the rule in the results.


How we fix when things go wrong with VirtualBox SSH ?

From our experience in managing VirtualBox, we often see customers having problems with SSH on guest VMs. Let’s see where customers go wrong in NAT setup and how we fix them.


1. Port problems

Often, problems can arise while choosing the SSH port. Recently, one of our customers reported problems with SSH access to his VirtualBox guest machine. The error said:

ssh: connect to host port 22:Connection refused

Here, our Support Engineers started investigation by checking the SSH configuration and the port forwarding rule. In this case, the forwarding rule was set up on port 2222, while customer was using 22 instead. And, we corrected the customer to use the correct SSH port and that fixed the problem.


2. Network settings

Similarly, network settings also can create problems with access to VirtualBox guests.

The network settings depend on the type of access required on guest VMs. For example, when the guest server need only access via internal network, our Dedicated Engineers setup the network interface as host-only adapter. Here, the machine will not have access to the internet.

And, for machines that need internet access too, we set the Adapter 1 as NAT and set Adapter 2 as a Host-Only adapter. Thus, when users report connection problems, we always ensure that the network adapter is set correctly on the server.

[Have trouble connecting to VirtualBox machine ? We can fix it right away.]



To conclude, VirtualBox SSH NAT settings decide on the access to the guest machines. Today, we saw how our Dedicated Engineers setup port forwarding rules to enable SSH access on guest machines and fix common problems with it.


Never again lose customers to poor server speed! Let us help you.

Our server experts will monitor & maintain your server 24/7 so that it remains lightning fast and secure.


var google_conversion_label = "owonCMyG5nEQ0aD71QM";


  1. squiggles

    It worked. Thanks!

  2. Antonio Moschitta

    Works, thank you!


Submit a Comment

Your email address will not be published. Required fields are marked *

Privacy Preference Center


Necessary cookies help make a website usable by enabling basic functions like page navigation and access to secure areas of the website. The website cannot function properly without these cookies.

PHPSESSID - Preserves user session state across page requests.

gdpr[consent_types] - Used to store user consents.

gdpr[allowed_cookies] - Used to store user allowed cookies.

PHPSESSID, gdpr[consent_types], gdpr[allowed_cookies]


Statistic cookies help website owners to understand how visitors interact with websites by collecting and reporting information anonymously.

_ga - Preserves user session state across page requests.

_gat - Used by Google Analytics to throttle request rate

_gid - Registers a unique ID that is used to generate statistical data on how you use the website.

smartlookCookie - Used to collect user device and location information of the site visitors to improve the websites User Experience.

_ga, _gat, _gid
_ga, _gat, _gid


Marketing cookies are used to track visitors across websites. The intention is to display ads that are relevant and engaging for the individual user and thereby more valuable for publishers and third party advertisers.

IDE - Used by Google DoubleClick to register and report the website user's actions after viewing or clicking one of the advertiser's ads with the purpose of measuring the efficacy of an ad and to present targeted ads to the user.

test_cookie - Used to check if the user's browser supports cookies.

1P_JAR - Google cookie. These cookies are used to collect website statistics and track conversion rates.

NID - Registers a unique ID that identifies a returning user's device. The ID is used for serving ads that are most relevant to the user.

DV - Google ad personalisation

IDE, test_cookie, 1P_JAR, NID, DV, NID
IDE, test_cookie


These are essential site cookies, used by the google reCAPTCHA. These cookies use an unique identifier to verify if a visitor is human or a bot.