A virtual machine behind NAT can reach the network without being directly reachable from its host. VirtualBox port forwarding opens a chosen host port and sends its incoming connections to a service inside the guest.
The host address determines who can reach that service. A rule bound to 127.0.0.1 accepts connections from the host itself; leaving Host IP empty allows connections through any host interface, which can expose the guest service to other computers.
The guest needs an SSH server running and an account that permits SSH login. Port forwarding provides the route to that server; it does not start the service, change the guest firewall, or replace SSH authentication.
The VM must use the per-adapter NAT attachment, rather than NAT Network. Begin with the guest shut down and its state shown as Powered Off. Host port 2222 must be unused.
Steps to configure NAT port forwarding in VirtualBox:
- Open Settings for the powered-off virtual machine in VirtualBox Manager.

- Switch the settings view to Expert.
Expert exposes the port forwarding controls in VirtualBox 7.2; older versions show them under Advanced in the network settings.
- Select Network in the settings sidebar.

- Open Port Forwarding for the adapter attached to NAT.
Adapter 1 is the NAT adapter shown here.
- Click the green plus icon to add a forwarding rule.

- Enter the SSH forwarding rule with the following values.
Field Value Name SSH Protocol TCP Host IP 127.0.0.1 Host Port 2222 Guest IP Leave empty for a guest using VirtualBox DHCP. Guest Port 22 Each cell is editable by double-clicking it. The host port is the address used by the SSH client; the guest port is where the SSH server listens. A guest with a manually assigned static address needs that address in Guest IP.
An empty Host IP can expose SSH through the host's network interfaces. 127.0.0.1 limits this rule to connections from the host. Removing this rule later with the minus icon, followed by both OK buttons, closes the forward.
- Click OK to accept the SSH forwarding rule.

- Click OK in the VM settings to save the change.

- Start the virtual machine from VirtualBox Manager.

- Connect to the guest over SSH from the host.
$ ssh -p 2222 user@127.0.0.1 Welcome to Ubuntu 26.04.1 LTS (GNU/Linux 7.0.0-43-generic aarch64) ##### snipped ##### user@ubuntu:~$
user is an account in the guest, not the host. Successful authentication opens the guest's shell, as shown by user@ubuntu. The guest must have finished booting before it can accept the connection.
On a first connection, the host key fingerprint needs comparison with the guest's key before acceptance.
A refused or closed connection can mean the guest SSH server is stopped, its firewall blocks port 22, or the rule points to the wrong guest address. An authentication error means the connection reached SSH but the account, key, or password was rejected.