Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't `ssh` onto Private Network

Tags:

ssh

vagrant

Given the following Vagrantfile:

# -*- mode: ruby -*-
# vi: set ft=ruby :

VAGRANTFILE_API_VERSION = "2"

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
  config.vm.box = "centos_64"
  config.vm.host_name = 'web'
  config.vm.network "private_network", ip: "192.168.50.4"
end

Why can't I ssh onto the guest from the host?

$ ssh vagrant@web -p 22
ssh: connect to host web port 22: Connection timed out

But using vagrant ssh works:

$ vagrant ssh
Last login: Tue Mar  4 21:29:24 2014 from 10.0.2.2
[vagrant@web ~]$

As expected, I can ping the IP Address from the guest. But I can't ping from the host.

I'm confused as to why it's happening since my setup does not look different from this configuration.

like image 236
Kevin Meredith Avatar asked Aug 16 '26 17:08

Kevin Meredith


1 Answers

First, vagrant ssh uses the forwarded port and not the private network address. You can get the configuration with vagrant ssh-config.

Is the name "web" really resolving to the specified IP? Can you ping/connect using the IP instead of the name? If not, verify that you don't have other VMs or external networks with the same address. Also some VPN products mess up the routing.

like image 162
tmatilai Avatar answered Aug 19 '26 18:08

tmatilai