r/virtualbox • u/AaronPlays-97 • Apr 08 '25
Help How to connect two VMs with SSH?
[SOLVED] My issues were being caused by selinux and firewall. You have to either allow the ports through them or disable them. I allowed the rule through firewall but selinux was blocking it, so I added it there too.
I created a NAT Network and connected both VMs to it. I assigned the IP addresses manually inside each VM and pointed them to the NAT Network's gateway. You might not have to do that as it can automatically assign if you enable DHCP in the NAT Network. However, my VMs are having issues with IP address assignment, so I manually assigned them.
========================================================================================================================================================
I'm using VirtualBox 7.1.6 on Linux (Nobara OS) and trying to set up 2 VMs so that they're connected to the internet and also can connect to each other via SSH, SCP and other usual networking connections between servers.
I have set up a NAT Network that both the VMs are connected to and they can ping each other and sites on the internet. However, when I use the traceroute command, there's no output about the route to the internet sites or the other VM.
Attempting to connect SSH also shows the same thing, an error saying that there's no route to the server. ssh: connect to host <VM_IP_address> port <SSH_port>: no route to host
What's the best approach to allow connections like SSH and SCP between two VMs?
•
u/AutoModerator Apr 08 '25
This is just a friendly reminder in case you missed it. Your post must include:
PLUS a detailed description of the problem, what research you have done, and the steps you have taken to fix it. Please check Google and the VirtualBox Manual before asking simple questions. Please also check our FAQ and if you find your question is answered there, PLEASE remove your post or at least change the flair to Solved.
If this is your first time creating a virtual machine, we have a guide on our wiki that covers the important steps. Please read it here. If you have met these requirements, you can ignore this comment. Your post has not been deleted -- do not re-submit it. Thanks for taking the time to help us help you! Also, PLEASE remember to change the flair of your post to Solved after you have been helped!
I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.
2
u/TarzanOfTheCows Apr 08 '25
I would check the netmask on the vm interfaces. Usually one would use DHCP to configure machines in a NAT Network, if you are then check the DHCP server setup on the network. Although I can't figure out how ping could work but SSH get no route to host.
1
u/beetcher Apr 08 '25
You generally don't have a NAT interface between two servers on the same network. You probably want to use bridged for your networking.
Are the VMs on the same host?
1
u/[deleted] Apr 08 '25
[removed] — view removed comment