Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Faster SSHing into vagrant

Running vagrant ssh can be slow because it boots up a ruby process, does a bunch of analysis to determine your ssh parameters, and then actually invokes the command. If you want a faster login, try the following:

# Compute the ssh parameters, append them to your global ssh config file
# The --host parameter specifies what you want the vagrant machine to be called
vagrant ssh-config --host vagrant >> ~/.ssh/config

# Now just ssh into that machine directly
ssh vagrant

A couple caveats:

  1. Vagrant still needs to be running for you to ssh into it. vagrant ssh fails with a helpful error message when the machine isn't running, while ssh vagrant will just fail silently. Not super helpful.
  2. If you do a bunch of fiddling with vagrant, it's possible that the parameters in your .ssh/config file may become out of date. I've been running this configuration for several months now without any problems but ymmv. To fix that issue, open your .ssh/config file, delete the block that starts with "Host vagrant" and then run the first command again.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.