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
You can take any of the ssh-config
arguments, and pass them to ssh on the commandline as -o Key=value
. So, for a simple one-host vagrant setup (you might have to do a little more work with grep
or perl
for a multihost setup), you can do something like the following (or replace perl
with sed
if you want):
ssh `vagrant ssh-config | tail -8 | perl -pe 's/^\s+/-o@/; s/\s/\=/;s/@/ /;s/\n/ /'` vagrant@localhost