Just pass the entire vagrant ssh-config
as a config file to ssh
with the -F configfile
parameter. The host alias to connect to is defined on the first line in vagrant ssh-config
; Host default
means you can connect with ssh default
.
I couldn't see an option to read the config file from the standard input, so went with the temp file route. Here's a one-liner that also cleans up the temporary $TMPDIR.vagrant-ssh-config
file afterwards. It needs to be executed in the same directory as your Vagrantfile
, assuming you vagrant box is up and running.
vagrant ssh-config > $TMPDIR.vagrant-ssh-config && ssh default -F $TMPDIR.vagrant-ssh-config ; rm $TMPDIR.vagrant-ssh-config
Note: on my Mac OSX system, $TMPDIR
expands to /var/folders/46/yltlhtgx8m5cg68_w95wgvy41324gn/T/
(right now). Use anotheranother variablevariable, or another folder, if it's not set on your system.