|- Tune /etc/ssh/sshd_config|
|UseDNS no # Disable DNS lookups|
|GSSAPIAuthentication no # Disable negotation of slow GSSAPI|
|don't forget to restart it, use a script provider to set it , or create it with veewee or snapshot it|
|- Tune Vagrantfile|
|vb.customize ["modifyvm", :id, "--natdnshostresolver1", "on"]|
|- Logging into the vm with a regular ssh command|
|vagrant ssh-config vmname | ssh -t -t -F/dev/stdin vmname|
|Use the -t -t to overcome the pseudoterminal warning|
|- Now use a control connnection for ssh|
|(as it seems that the cli invocation of vagrant takes a couple of seconds ....)|
|Setup the control session:|
|vagrant ssh-config vmname | ssh -t -t -F/dev/stdin -o 'ControlMaster auto' -o 'ControlPath ~/.ssh/vagrant' vmname|
|Use it for fast login|
|ssh -o 'ControlMaster auto' -o 'ControlPath ~/.ssh/vagrant' vmname|
|Now it logins in a matter of milliseconds!|
For those new to Vagrantfile setup, the
And, in this case, it assumes you are using VritualBox.
This has worked! From 7 seconds regular ssh to almost instant. Am on macOS Sierra 10.12.6 with Centos as guest.
On top of the above, I also copied the output of
I have been looking for a solution for slow Vagrant ssh connections on Mac for months (though interrupted by daily work).
Just in case someone is in doubt, I ran