Fill in the address, gateway, netmask based on checked host-only IP address.
$ sudo vim /etc/network/interfaces
# interfaces(5) file used by ifup(8) and ifdown(8)
auto lo
iface lo inet loopback
auto eth1
iface eth1 inet static
address xxx.xxx.xxx.xxx
gateway xxx.xxx.xxx.xxx
netmask xxx.xxx.xxx.xxx
Reboot after setting gives us to connect Ubuntu using ssh like this. “ssh username@guest IP address”.
Make start-up script
Make start-up script and ssh connect script.
$ mkdir -p ~/myscript
$ vim ~/local-login
#! /bin/sh
isstarted=`ps aux | grep -c "GuestName"`
if [ $isstarted -eq 1 ]; then
VBoxManage startvm GuestName -type vrdp
sleep 5
else
VBoxManage controlvm GuestName resume
fi
ssh username@guest IP address
remain=`ps -e -o args | grep -c "^ssh.*GuestName"`
if [ $remain -eq 0 ]; then
VBoxManage controlvm GuestName pause
echo vm paused.
fi
echo bye
$chmod 755 ~/myscript/local-login
GuestName part is virtual machine’s name、 username part is guest OS’s username、guest IP address part is guest OS’s IP address is set.
And then, write the script path to .bash_profile.