I am trying to set up a cluster of VMs on my Ubuntu laptop so that I can test some distributed code. My goal is to execute a shell script that will spin up the configuration and another script to tear it down when I'm done testing.
I need to be able to SSH into all of the VMs to install the software and I would like to do that over LAN. I am not interested in using the GUI to do this because I would like the process to be automated. I am starting by booting one VM and am trying to forward port 2222 with the following script:
NAMES=(node1)
for i in ${NAMES[@]}; do
vboxmanage createvm --name ${i} --ostype "Ubuntu_64" --register
vboxmanage modifyvm ${i} --nic1 nat --nic2 hostonly --hostonlyadapter2 vboxnet0 --memory 1024 --natpf1 "openssh,tcp,,2222,,22"
vboxheadless -s ${i}
done
After running ifconfig
I get the following for vboxnet0
:
vboxnet0 Link encap:Ethernet HWaddr 0a:00:27:00:00:00
inet addr:192.168.56.1 Bcast:192.168.56.255 Mask:255.255.255.0
inet6 addr: fe80::800:27ff:fe00:0/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:113 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 B) TX bytes:19687 (19.6 KB)
But when I run ssh -p 2222 [email protected]
I get the following error:
ssh_exchange_identification: read: Connection reset by peer
Perhaps I am approaching this problem incorrectly (I am not terribly well versed in networking), but would appreciate some insight either way.