SSH into Ubuntu Server VM

Discussions related to using VirtualBox on Windows hosts.
Post Reply
tonelabaudio
Posts: 4
Joined: 10. Jan 2022, 02:36

SSH into Ubuntu Server VM

Post by tonelabaudio »

Hello all. First time post. I have setup an Ubuntu Server VM and am trying to SSH into the VM from the same PC that the VM is running on. I have successfully done so when the network was set to NAT. I would then set a forwarding rule. The only problem there was that I was unable to access Apache2 from the localhost browser. I suppose that this was becausse the VM IP was out of my internal network's IP range (I believe that it was assigned 10.0.2.15) My PC is assigned 10.0.0.50

I set the network to Bridged Adapter and noticed that the IP was now 10.0.0.61. Great! The only problem that I am having now is that I am unable to SSH into the Ubuntu VM. I try ssh peter@10.0.0.61 and get the connection refused error message. Your time and assistance will be greatly appreciated. Thank you!
BillG
Volunteer
Posts: 5102
Joined: 19. Sep 2009, 04:44
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Windows 10,7 and earlier
Location: Sydney, Australia

Re: SSH into Ubuntu Server VM

Post by BillG »

Bridged mode will only work if your host is on a LAN which has a DHCP server. If this is the case, the vm should get its network config from that DHCP server, and would normally be in the same IP subnet as the host (so you would not need forwarding). What is the network config of the host? Does it have a 10.0.0.x IP address? Can you ping one from the other?
Bill
tonelabaudio
Posts: 4
Joined: 10. Jan 2022, 02:36

Re: SSH into Ubuntu Server VM

Post by tonelabaudio »

BillG wrote:Bridged mode will only work if your host is on a LAN which has a DHCP server. If this is the case, the vm should get its network config from that DHCP server, and would normally be in the same IP subnet as the host (so you would not need forwarding). What is the network config of the host? Does it have a 10.0.0.x IP address? Can you ping one from the other?
Hello and thank you so much for your prompt response. As can be seen in the attached screenshot(s) I have Adapter 1 set to bridged adapter and am able to ping the Ubuntu server at 10.0.0.61. The IP of the Windows 10 PC that I am attemtping to reach the VM from has an IP address of 10.0.0.51

Unfortunately, I am unable to attach links or images at this time.
tonelabaudio
Posts: 4
Joined: 10. Jan 2022, 02:36

Re: SSH into Ubuntu Server VM

Post by tonelabaudio »

BillG wrote:Bridged mode will only work if your host is on a LAN which has a DHCP server. If this is the case, the vm should get its network config from that DHCP server, and would normally be in the same IP subnet as the host (so you would not need forwarding). What is the network config of the host? Does it have a 10.0.0.x IP address? Can you ping one from the other?
DHCP = Yes
Ping = Yes
Host address - 10.0.0.51 (Windows 10 Pro) Wi-Fi
Wi-Fi network adapter chosen in Bridged Adapter name dropdown

I am stumped!
fth0
Volunteer
Posts: 5668
Joined: 14. Feb 2019, 03:06
Primary OS: Mac OS X other
VBox Version: PUEL
Guest OSses: Linux, Windows 10, ...
Location: Germany

Re: SSH into Ubuntu Server VM

Post by fth0 »

The SSH error "Connection refused" usually means that someone actively answered the TCP SYN packet with a TCP RST packet. This could be either on the host (e.g. Windows Firewall, some so-called security software) or in the guest (e.g. SSH server, network setup). In the guest, you could for example start checking with netstat -tuna and/or tail -f /var/log/syslog (or similar).
scottgus1
Site Moderator
Posts: 20965
Joined: 30. Dec 2009, 20:14
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Windows, Linux

Re: SSH into Ubuntu Server VM

Post by scottgus1 »

In addition to BillG's and fth0's comments, try to ping between host and VM. Note that some OS families' firewalls block ping, or ICMP Echo Request. Unblock such in the host and VM OS firewalls then try ping on the Bridged network.

If ping gets through, the network is working, and failures are being caused by config issues in the host or VM OS, not Virtualbox.
tonelabaudio wrote:Unfortunately, I am unable to attach links or images at this time.
Images can be posted using the forum's Upload Attachment tab on the first day first post.
tonelabaudio
Posts: 4
Joined: 10. Jan 2022, 02:36

Re: SSH into Ubuntu Server VM

Post by tonelabaudio »

Thank you all for taking the time to assist me. I really do appreciate it immensely. Don't I feel like the fool this morning. In my haste (frustration) I did not take a minute to verify it the SSH service was actually running. Although, I know for a fact that it had been because I have been accessing the VM for over a week. So I:

service ssh start
systemctl status ssh
ufw allow ssh
ufw enable
ufw status

All's well that ends well. Forgive me for having taken up your precious time. Have yourselves a safe and wonderful Monday. Peter
Last edited by tonelabaudio on 11. Jan 2022, 03:39, edited 1 time in total.
scottgus1
Site Moderator
Posts: 20965
Joined: 30. Dec 2009, 20:14
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Windows, Linux

Re: SSH into Ubuntu Server VM

Post by scottgus1 »

No problem! Glad you're up and running.
Post Reply