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

Setup

  • Windows 7 64-bit host OS running VirtualBox 4.2, with Ubuntu 12.04 guest OS.
  • OpenSSH server is installed and running (ssh -v localhost connects locally in the guest machine).
  • Can SSH to external servers (no outbound Windows firewall rule blocking port 22)
  • Can ping the IP of the guest (192.168.56.101)

Problem

Using PuTTY to SSH to the IP of the guest OS (192.168.56.101), PuTTY returns almost immediately with

Network error: connection refused

How can I diagnose & resolve this issue?

share|improve this question

Are you sure the IP is for the guest OS. I had the same problem and it turned out that the IP I had been using all along, the 192.168.56.101 was actually the Windows interface IP and the host OS IP was 192.168.56.103.

You can verify by doing ipconfig / ifconfig on both.

NOTE: I had also setup a static IP which it turns out I didn't need at all. In case you try from the start I found this tutorial to be better.

share|improve this answer
5  
+1, The VirtualBox default is to create a guest whose virtual network adapter is NAT'ed through VirtualBox itself. Therefore such a guest would be able to SSH out, and would be able to SSH itself, but it would not be able to receive SSH connections until Port Forwarding rules were created in VirtualBox. – Gord Thompson Mar 17 '13 at 12:30
    
+1 After 1h of Google-mess, finally! I thought the .101 was the guest not the host! – 5chdn Jul 8 '14 at 17:33

You should check that your guest OS firewall is not blocking incoming connections on port 22.

share|improve this answer
1  
The guest OS firewall is disabled. That is the default, and I verified it is disabled with sudo ufw status. – Eric J. Sep 25 '12 at 3:22

Maybe it's an issue with access control. To disable it and allow full access, as root:

xhosts +

I had a similar issue with VNC viewer

share|improve this answer
1  
I really doubt that, IMHO sshd has nothing to do with X -- in contrast to vnc. – mpy Mar 16 '13 at 20:44

Problem was solved by enabling the DHCP server on the VirtualBox network adapter.

VirtualBox (latest version, version 5) -> File -> Preferences -> Network -> Host-only networks (tab) -> Host-only networks details (Icon tool) -> DHCP Server

  1. Tick Enable Server
  2. Fill in the IP address
  3. OK, OK
  4. Restart the virtual machine

My settings for step 2

  1. Server Address: 192.168.56.100
  2. Server Mask: 255.255.255.0
  3. Lower Address Bound: 192.168.56.101
  4. Upper Address Bound: 192.168.56.200
share|improve this answer

The following works for me:

Before:

vboxnet0: 192.168.56.1
eth1:     192.168.56.1

After:

vboxnet0: 192.168.56.1
eth1:     192.168.56.101

So, basically I changed part of the file { /etc/network/interfaces } as follows:

Before:

auto eth1
iface eth1 inet static
address 192.168.56.1
netmask 255.255.255.0 

After:

auto eth1
iface eth1 inet static
address 192.168.56.101
netmask 255.255.255.0 

Works: ssh username@192.168.56.101

share|improve this answer

Secure Shell (SSH) is a protocol for logging into and executing commands on remote machines. It provides secure encrypted communications. If you plan on accessing your machine remotely via SSH over a firewalled interface, enable this option. You need the openssh-server package installed for this option to be useful.

Here comes the information that the package openssh-server has to be installed. After doing that on the guest and a restart of the vm you can use ssh.

share|improve this answer

In your Linux box (VirtualBox Ubuntu), open the Terminal and enter the following command: sudo service ssh start

Try connecting to it again after this

Oh my bad I missed what gronostaj pointed out

OK sometimes the solutions are really simple. recently I faced the same issue with Slackware guest on windows 7 host. All i had to do was ifconfig up eth'X' and assign IP 192.168.56.xxx sub net 255.255.255.0 (if host only adapter) This question is almost one year old, so I'm mentioning this for someone like me stumbles on this page searching for "ssh connection refused" ;-)

share|improve this answer
    
OP had stated that local SSH connections work, so the server is running. – gronostaj Mar 16 '13 at 22:02

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.