Closed mlafeldt closed 10 years ago
Fyi, seems that Vagrant 1.4 will use OpenSSH for vagrant ssh -c
, which is much faster than Net::SSH
.
@tmatilai Ah, thanks for the info!
I'm not really happy with this PR anyway, mainly because it only works with VirtualBox (and asking for the port is pretty dirty).
Will keep this open a bit longer and see how it works out.
@tmatilai @fgrehm
I've got an idea: What if we had a Vagrant plugin that would automatically manage an SSH config file for each machine, e.g. under .vagrant/machines/$machine_name/ssh_config
. The plugin would save/update the config whenever a machine is started, making sure that external tools can rely on that info for (fast) SSH access. Also, if the Vagrant machine has a private IP address, the plugin would favor it over the slower SSH port forwarding.
What do you think? chef-runner might not be the only tool that could benefit from such a plugin.
@mlafeldt unfortunately I haven't had a chance to try out this project yet but what you wrote about this new plugin makes sense :)
Fyi, seems that Vagrant 1.4 will use OpenSSH for vagrant ssh -c, which is much faster than Net::SSH.
I just did some benchmarks.
Vagrant 1.3.5
$ time vagrant ssh -c uname
Linux
real 0m1.996s
user 0m1.147s
sys 0m0.383s
Vagrant 1.4.0.dev
$ time vagrant ssh -c uname
You appear to be running Vagrant outside of the official installers.
Note that the installers are what ensure that Vagrant has all required
dependencies, and Vagrant assumes that these dependencies exist. By
running outside of the installer environment, Vagrant may not function
properly. To remove this warning, install Vagrant using one of the
official packages from vagrantup.com.
Linux
Connection to 127.0.0.1 closed.
real 0m1.307s
user 0m0.618s
sys 0m0.289s
Pure SSH
$ time ssh practicingruby.local uname
Warning: Permanently added '10.11.12.13' (RSA) to the list of known hosts.
Linux
real 0m0.309s
user 0m0.019s
sys 0m0.006s
I think I can live with the 1 second gap between Vagrant 1.4 and pure SSH. As I wrote earlier, I'm not happy with this PR anyway. It's a VirtualBox-specific hack, nothing more. I'm going to document another SSH trick I've been using (SSH connection sharing and persistence) and leave this as-is. People can always choose to use pure SSH if they really need a maximum of speed.
Instead of asking the user to set up a static SSH config for each Vagrant machine, use
vagrant ssh-config
to request SSH settings on demand and cache them somewhere.For this to work properly, the cache needs to be invalidated as soon as the machine's state changes (e.g. via
vagrant reload
). Not sure how to accomplish that without some sort of state machine. Ideas are welcome.Update: One way to solve the caching problem might be to ask Vagrant for the ssh config once and then query VirtualBox for the current SSH port (forwarding). See https://github.com/dergachev/vgrnt/blob/master/lib/vgrnt/util/virtualbox.rb