- Host IP - 192.168.99.1
- Guest IP - 192.168.99.2
- NAT interface (#1) - enp0s3
- Host-only interface (#2) - enp0s8
- OpenSSH in both host and guest
Change the IP addresses as your setup.
- Enable second network adapter as host only interface:
VBoxManage modifyvm "Ubuntu" --nic2 hostonly
VBoxManage modifyvm "Ubuntu" --hostonlyadapter1 "VirtualBox Host-Only Network"
- Add static private IPv4 address in host only interface:
netsh interface ip set address "VirtualBox Host-Only Network" static 192.168.99.1 255.255.255.0
- Add static private IPv4 address in guest:
Add the IP address in Network Manager or Add these lines in
# NAT network interface
iface enp0s3 inet dhcp
# Host-Only network interface
iface enp0s8 inet static
Restart network interfaces with
sudo ifdown -a; sudo ifup -a command.
ssh-keygen -t rsa
- Add port forwarding in NAT interface:
VBoxManage modifyvm "Ubuntu" --natpf1 "guestssh,tcp,127.0.0.1,3022,192.168.99.2,22"
- Restart VM and SSH with
ssh -p 3022 user@localhost.
VirtualBox Manual: VboxManage