Tell me more ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

Local Vagrant machine installed at ip address 10.0.0.23 and hostname lamp-vm. Using vagrant ssh I can connect just fine and do everything I need.

This creates an ERROR - ssh vagrant@lamp-vm -v -v and I get

debug1: connect to address 10.0.0.23 port 22: Connection timed out
ssh: connect to host lamp-vm port 22: Connection timed out

My etc/hosts file contains 10.0.0.23 lamp-vm.

My .ssh/config file looks like
Host lamp-vm
User vagrant
IdentityFile ~/.ssh/vagrant

I have tried the ssh command with and without the -i /path/to/.sh/identity_file as well.

How do I connect to my Vagrant Virtual Machine using SSH?

share|improve this question

4 Answers

This behavior is by design.

Vagrant uses VirtualBox NAT mode which means using port forwarding.

You can't SSH directly to your VM using NAT mode.

Using 'vagrant ssh' means vagrant will do the port forwarding for you so you don't have to worry about it. I think it will connect to localhost on port 2222 by default but it will try to also sort out any port number collisions.

If you need to SSH directly to your VM, switch the VM into host-only or bridged networking mode.

share|improve this answer
Thanks Philip but how would I go about solving that? Sorry for the inexperience. – Christopher Ickes Oct 23 '12 at 16:41
I am using host-only mode and the problem persists. – Christopher Ickes Oct 23 '12 at 17:01

I would have added this as a comment, but I currently do not have enough rep to do so. I've written a how-to for setting your VM to bridged mode here:

http://askubuntu.com/questions/116861/setting-up-a-network-between-a-host-and-guest-virtual-machine/116909#116909

I hope you find this useful!

share|improve this answer
+1 here and on AU.SE; nice write-up. – msanford Oct 23 '12 at 18:25

Can you ping the VM Christopher? It defiantly sounds like a small networking issue. Were you able to set it for bridge networking mode?

share|improve this answer

Destroyed the virtual machine
Reloaded the virtual machine
Everything worked

Not sure why but obviously something didn't load properly on the first provisioning.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.