Vagrant direct SSH

I do all of my work in Dropbox for safety and easy portability. I know … you might be thinking that’s what version control is for, but sometimes I will get interrupted and have to run away from my PC before I can commit. By using Dropbox I can get interrupted and jump on to any one of my other PCs at home or the office and pick up exactly where I left off. I also get access to versions of uncommitted files.

The small issue that I have with this setup is that I also work in a Vagrant environment and that doesn’t work very well in a Dropbox based setup. When I vagrant up on the new pc, the existing Vagrant command line on my original PC loses contact with my already active Virtualbox — meaning, when I return to the original PC and run vagrant ssh it tells me that there is no Vagrant instance active.

Typically to solve this issue I have to vagrant destroy then vagrant up again, but this is really annoying and needlessly time consuming.

I finally took the time to solve this issue by adding Vagrant to my ~/.ssh/config file.

If you don’t understand all of the lines above then you can read up on SSH. Basically, by adding this to your ssh config file it will reduce the normal command ssh [email protected] -p 2222 -o Compression=yes -o DSAAuthentication=yes -o LogLevel=FATAL -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o IdentitiesOnly=yes -i ~/.vagrant.d/insecure_private_key to the simply ssh vagrant -p 2222

So, after I add that I can just run ssh vagrant -p 2222 to gain access just as easily as vagrant ssh

 Dave

About David Parlevliet

Dave is long time developer with a passion toward teaching. He divides his time between his wife, her cat and his projects. He recently started using twitter so make sure to follow him!