How to ssh to vagrant without actually running “vagrant ssh”?

后端 未结 16 1541
清酒与你
清酒与你 2020-11-29 15:07

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

16条回答
  •  攒了一身酷
    2020-11-29 15:25

    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

提交回复
热议问题