How to ssh to vagrant without actually running "vagrant ssh"?
There's a lot of answers already, but they all seem overly complicated or solve problems the asker didn't have.
simply:
# save the config to a filevagrant ssh-config > vagrant-ssh# run ssh with the file.ssh -F vagrant-ssh default
I've had to re-implement "vagrant ssh" because it's -c
option didn't pass on arguments properly. This is basically what it does (there might be more, but it works fine this way)
#!/bin/shPORT=$(vagrant ssh-config | grep Port | grep -o '[0-9]\+')ssh -q \ -o UserKnownHostsFile=/dev/null \ -o StrictHostKeyChecking=no \ -i ~/.vagrant.d/insecure_private_key \ vagrant@localhost \ -p $PORT \ "$@"
As a one-liner (with thanks to kgadek):
ssh $(vagrant ssh-config | awk 'NR>1 {print " -o "$1"="$2}') localhost
To account for when you have more than one vagrant host, this will select the desired host, as well as cull blank lines from the config (using sed):
HOST=name-of-my-hostssh $(vagrant ssh-config $HOST | sed '/^[[:space:]]*$/d' | awk 'NR>1 {print " -o "$1"="$2}') localhost
In terminal run
vagrant ssh
In another terminal window/tab run
ps aux | grep ssh
There you will see the actual command executed by Vagrant, something like this:
ssh vagrant@127.0.0.1 -p 2222 -o Compression=yes -o DSAAuthentication=yes -o LogLevel=FATAL -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o IdentitiesOnly=yes -i ~/.vagrant.d/less_insecure_private_key -o ForwardAgent=yes