Score:2

How to access a cloned VirtualBox Ubuntu Server via SSH to get a different Address

am flag
Max

I installed a headless Ubuntu server build on VirtualBox, and once I fully prepared it to work, I cloned it to have a second, exactly the same, instance. However, the clone shares it's CMD SSH access and since that happened, I cannot access it.


Edit: I cannot access it while the other is accessed at the same time. If I turn one off, the other works.


Is there any way to assign a new SSH key so I can access both servers on different cmds at the same time?

ru flag
This is an IP conflict issue. Revise the network address on one of the servers to be different, and change the MAC addresses in the VM's settings in your VM configuration in Virtualbox to be a different MAC address. You'll have to open the VM console and login on the console of the VM itself to handle the networking changes.
Score:4
ph flag

I very often do something similar where I install a new version of Ubuntu and keep that pristine version for cloning (which is a lot faster than re-installing each time).

  1. To create a clone, I stop that instance (sudo init 0).
  2. Create the clone
  3. Boot the clone
  4. Edit the network setup of the clone

Since Ubuntu 18.04, I edit the netplan file, usually:

vim /etc/netplan/50-cloud-init.yaml

then assign a new address to the server and reboot to make sure it works as expected (especially, I also change the hostname and want to make sure it survives a reboot).

Once that works, I can start both servers in parallel since they now each have a different IP address.

You could also use DHCP because in that case each computer is automatically assigned an IP address. Only that can be complicated to setup other tools as one and/or the other IP may change without notice and you'd have to edit your setup (unless you can use a DNS to give each computer a name). The DHCP server also has an option to use the computer MAC address and force a specific IP for each specific computer. I often use that feature for external devices (however, the iPhone OS just change their code to dynamically change the MAC address on us... not sure how much more secure that can possibly be... since that way I can't verify who is connecting where if that's an iPhone!)

As for the SSH keys, you can simply put your key in your VPS accounts as you would normally do. The same key can be reused any number of times (i.e. put the public key in all your VPS ~/.ssh/authorized_keys file).

If you'd like to directly connect between your VPS, you also need to copy the private key to said VPS. However, keep in mind that by default the VirtualBox servers appear on the Internet (unless you have a strong firewall setup). So placing your private keys in your VPS is not advised.

am flag
Max
Thanks! I will try that method and see how that goes. The VPS will only be used for internal company purposes, so there shouldn't be any interaction with the outside world other than internet. But the servers that actually keep the info will be secure somewhere else.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.