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.
For this tutorial, I’m using an Ubuntu client. The ISO for that can be found here.
Create the CentOS server and your client virtual machines.
Setup the CentOS VM.
a. Open Installation Destination and press Back.
b. Go to Network & Hostname if you want to change your hostname, which I recommend.
c. Feel free to configure items under Localization. Everything else is handled automatically by VirtualBox.
d. Press begin installation.
e. Create both a root account and a normal account. Make sure the latter has administrator rights.
f. Once the loading bar is full, press Reboot.
Setup your client VM.
a. Install VirtualBox guest additions.
Part II – Virtual Network Configuration
In VirtualBox, press CTRL+W.
Create a new host network.
a. If you receive an error, this is likely due to your host OS causing VirtualBox problems installing its drivers. You will need to fully uninstall VirtualBox and reinstall the latest version. Make sure to run the installation as admin.
Under the Adaptor tab, select “Configure Adapter Manually”
For Windows, open the Command Prompt and type ipconfig.
Scroll through the output until you find the name of the host-only network you just created. Use this IPv4 Address and Mask for the VirtualBox network configuration.
Close the Host Network Manager.
Open the settings of your client VM. Under Network, Enable Adapter 2, select Host-only Adapter and then the name is the name of your newly-created host-only network.
Repeat the last step for your CentOS server VM. Additionally, go to Adapter 1’s Port Forwarding under the Advanced tab and create a new rule. Set both the host and guest ports to 22.
Before closing the advanced settings, note the MAC address.
Part III – Server Configuration
Launch your CentOS VM.
Run yum check-update, yum upgrade, and yum clean all.
Hit enter over “Edit a connection.”
You should see “enp03s” and a “Wired Connection 1”.
a. If you have two connection options but are unsure of which is which, go to edit one. If the device value matches the MAC address seen under Adapter 1 from Part II, then it’s your NAT connection, otherwise its your host-only connection.
Edit your Host-only connection:
a. Set IPv4 configuration to “manual.”
b. Show IPv4 configuration
c. In VirtualBox, press CTRL+W. Next to your Host-only network name, you should see and IP Address/Mask combination of the form “[ip]/[mask].” On your server under IPv4 configuration, this is what you will type after pressing <Add…>.
d. Go down and press OK.
Make sure “Automatically connect” is checked for both your Host-only and NAT connections.
Navigate out of nmtui and reboot.
Part IV – Client Configuration & Usage
Boot your Client VM.
(optional) Edit /etc/hosts to include the a line of the form:
Where serv_ip_addr is the ip address of your CentOS server (second output of hostname -I in your CentOS terminal). This will allow you to use whatever you chose for [hostname] interchangeably with the ip address of your server. I typically just set this to the hostname chosen in part II.
If everything worked up to this point, you should be able to ssh [user]@[hostname] into your CentOS server. If this is not the case, you may need to install openssh-client and openssh-server on your machines.
Part V – Serving Up Websites
This is an excellent guide on hosting your own websites from a setup as described above.
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.
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"