Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

  • lo:
  • p2p1:
  • p7p1: (from dhcp)

I can SSH to the guest from the host using either vagrant ssh or ssh -p 2222 vagrant@ 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 vagrant@, 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 vagrant@, 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 vagrant@ on FC19 host:

$ ssh -vvv -p 22 vagrant@
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 [] port 22.
debug1: connect to address port 22: Connection refused
ssh: connect to host port 22: Connection refused

Output from ssh -p 22 vagrant@ on Windows host (when failing):

$ ssh -vvv -o LogLevel=DEBUG3 -i /c/Users/xxx/.ssh/vagrant -p 22 vagrant@
OpenSSH_4.6p1, OpenSSL 0.9.8e 23 Feb 2007
debug2: ssh_connect: needpriv 0
debug1: Connecting to [] port 22.
debug1: connect to address port 22: Connection refused
ssh: connect to host port 22: Bad file number
share|improve this question
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. – tchester Sep 27 '13 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. – tchester Sep 27 '13 at 23:25
Related: how to ssh to a VirtualBox machine? – kenorb Aug 1 '15 at 12:59

Your Answer


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

Browse other questions tagged or ask your own question.