Created
March 7, 2019 21:13
-
-
Save brian-pane/9f659c4ea84d4ea7810fbf36f1bf0a3e to your computer and use it in GitHub Desktop.
ssh setup for Ubuntu 18 on VirtualBox on macOS
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| My configuration to run Ubuntu on VirtualBox on macOS with both NAT and host-only network interfaces. | |
| Overview | |
| ======== | |
| The Ubuntu guest has two network interfaces: a primary NAT interface to enable it to reach | |
| the Internet (so things like apt will work) and a second, host-only interface to support SSH | |
| from the macOS host. | |
| Setup Steps | |
| =========== | |
| 1. Install Ubuntu 18 on VirtualBox with the default NAT network config | |
| 2. Shut down the Ubuntu VM | |
| 3. Create a host-only network on the macOS host: | |
| VBoxManage hostonlyif create | |
| This will create a network called vboxnet0. | |
| 4. View the new host-only network’s configuration: | |
| VBoxManage list -l hostonlyifs | |
| The output will look something like this: | |
| Name: vboxnet0 | |
| GUID: 0000-0000-0000-0000-0000 | |
| DHCP: Disabled | |
| IPAddress: 192.168.56.1 | |
| NetworkMask: 255.255.255.0 | |
| IPV6Address: | |
| IPV6NetworkMaskPrefixLength: 0 | |
| HardwareAddress: 00:00:00:00:00:00 | |
| MediumType: Ethernet | |
| Wireless: No | |
| Status: Up | |
| VBoxNetworkName: HostInterfaceNetworking-vboxnet0 | |
| In this example, based on the IPAddress and NetworkMask values, the | |
| host-only network is 192.168.56.0/24. | |
| 5. In the VirtualBox GUI, select the Ubuntu VM, click Settings, then Network, | |
| then “Adapter 2." 6. Click “Enable Network Adapter” and select “Host-only Adapter” | |
| in the “Attached to” dropdown. Choose “vboxnet0” in the “Name” dropdown. Click OK. | |
| 6. In the VirtualBox GUI, start the Ubuntu guest. | |
| 7. Log into the Ubuntu guest and create a file /etc/netplan/00-static-ip.yaml containing: | |
| network: | |
| version: 2 | |
| renderer: networkd | |
| ethernets: | |
| enp0s8: | |
| dhcp4: no | |
| addresses: [192.168.56.99/24] | |
| gateway4: 192.168.56.1 | |
| nameservers: | |
| addresses: [127.0.0.53] | |
| In this example, 192.168.56.99 is the IP address of the Ubuntu guest on the | |
| host-local network. | |
| 8. On the Ubuntu guest, | |
| sudo netplan --debug apply | |
| ifconfig | |
| The output of ifconfig should show that the enp0s8 interface now has IPv4 | |
| address 192.168.56.99. | |
| 9. Reboot the Ubuntu VM and verify that the interface still has that address. | |
| 10. From the macOS host, you can now ssh to 192.168.56.99 to reach the Ubuntu guest. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment