Created
January 18, 2019 16:36
-
-
Save Ryanauger95/55c81ad6ea837ef31cb28f01b304a9b6 to your computer and use it in GitHub Desktop.
Easily Start, Stop, and SSH into VB for Mac
This file contains 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
box() { | |
case $1 in | |
## Turn on VM and enter an SSH terminal | |
"vm") | |
## Start the VM if it is not already running ## | |
VBoxManage startvm "Ubuntu 16.04" --type headless > /dev/null 2>&1 | |
## Get the Ip address ## | |
Ip=$(VBoxManage guestcontrol "Ubuntu 16.04" --username <user> --password <pass> run /sbin/ifconfig | grep "inet addr" | grep "Bcast" | awk -F':' '{print $2}' | awk '{print $1}') | |
## SSH into the VM ## | |
ssh mangoh@$Ip | |
## Turn off the VM | |
"vmoff") | |
VBoxManage controlvm "Ubuntu 16.04" savestate | |
;; | |
## add any other box commands... For example, I add local Ip addresses to SSH into | |
*) | |
esac | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment