I would like to reproduce the way Vagrant logs in to my VM within a shell script using an ssh
command, so I create an alias to my Vagrant instance.
What
If you just want the bare minimum command to connect to your box, you need to know the port that it's using (printed when doing vagrant up
, or visible doing vagrant ssh-config
) and where's your private SSH key (also visible when doing vagrant ssh-config
)
Then it's just a matter of providing the key and port:
ssh -p 2222 -i $HOME/vagrantenv/.vagrant/machines/default/virtualbox/private_key vagrant@127.0.0.1