1

I have a Vagrant guest VM running FC18 on a host running FC19. The guest vagrantfile includes public networking (config.vm.network 'public_network'). After a vagrant up, I can see (ifconfig) three network interfaces on the guest:

  • lo: 127.0.0.1
  • p2p1: 10.0.2.15
  • p7p1: 10.3.76.86 (from dhcp)

I can SSH to the guest from the host using either vagrant ssh or ssh -p 2222 [email protected] which is using the auto assigned 2222 (host) -> 22 (guest) port forwarder on the automatically created private network. If I attempt to ssh from the host to the public network on the guest using: ssh -p 22 [email protected], I get an SSH response of: Connection refused. That's weird but even weirder is that if I move to a completely different (Windows) host (on the same network) and run ssh -p 22 [email protected], I can (occasionally), successfully, connect. I say occasionally because I have to repeat the ssh command 10 or 15 times (getting a response of bad file number), before I eventually get a successful SSH connection. If I leave the SSH prompt open for 3 or 4 minutes it disconnects with a connection reset by peer message.

What's going on here? How do I get reliable SSH to the public network on the guest? Before you suggest it, SELinux is in permissive mode on both guest and host and I have stopped the iptables service on both. The network also supports many SSH connections between other hosts without issues. The Vagrant guest can also SSH without issue to other hosts. It's only when SSHing to the Vagrant guest, that we get these strange errors.

Output from ssh -p 22 [email protected] on FC19 host:

$ ssh -vvv -p 22 [email protected]
OpenSSH_6.2p2, OpenSSL 1.0.1e-fips 11 Feb 2013
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 50: Applying options for *
debug2: ssh_connect: needpriv 0
debug1: Connecting to 10.3.76.86 [10.3.76.86] port 22.
debug1: connect to address 10.3.76.86 port 22: Connection refused
ssh: connect to host 10.3.76.86 port 22: Connection refused

Output from ssh -p 22 [email protected] on Windows host (when failing):

$ ssh -vvv -o LogLevel=DEBUG3 -i /c/Users/xxx/.ssh/vagrant -p 22 [email protected]
OpenSSH_4.6p1, OpenSSL 0.9.8e 23 Feb 2007
debug2: ssh_connect: needpriv 0
debug1: Connecting to 10.3.76.86 [10.3.76.86] port 22.
debug1: connect to address 10.3.76.86 port 22: Connection refused
ssh: connect to host 10.3.76.86 port 22: Bad file number
3
  • There is a recommendation when creating vagrant boxes to disable DNS on the ssh daemon by adding "DNS no" to the /etc/ssh/sshd_config file on your vagrant boxes and then restarting the SSH service. This will disable DNS lookups of the clients trying to connect to the vagrant box which may be the issue with your sporadic connections.
    – user87883
    Sep 27, 2013 at 23:21
  • In a few instances after I first did a "vagrant up" on a new box I found I needed to restart networking services before SSH worked properly. On Ubuntu I just added "/etc/init.d/networking restart" to the /etc/rc.local file. I am not sure what the equivalent Fedora process is.
    – user87883
    Sep 27, 2013 at 23:25
  • Related: how to ssh to a VirtualBox machine?
    – kenorb
    Aug 1, 2015 at 12:59

0

You must log in to answer this question.

Browse other questions tagged .