Skip to content

Instantly share code, notes, and snippets.

@mlafeldt
Created November 24, 2013 19:10
Show Gist options
  • Save mlafeldt/7631064 to your computer and use it in GitHub Desktop.
Save mlafeldt/7631064 to your computer and use it in GitHub Desktop.
Ask VirtualBox for current SSH port of a Vagrant machine
machine_name=default
machine_id=$(cat ".vagrant/machines/$machine_name/virtualbox/id")
ssh_port=$(VBoxManage showvminfo "$machine_id" --machinereadable | grep ^Forwarding | head -n1 | cut -d, -f4)
echo $ssh_port
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment