Duplicate Virtual Machines: Difference between revisions

From Proxmox VE
Jump to navigation Jump to search
Line 29: Line 29:


This is done at the host level, so is guest OS independent.
This is done at the host level, so is guest OS independent.
== How to change the SSH keys ==
The SSH host keys should be unique of each machine, much like MAC address above, but for security reasons. So, after duplicating a virtual machine as a new one, you need to re.generate the vm host ssh keys.
* ON a Linux OS
** access a vm terminal as root
** remove the previous keys like: <code>"#rm /etc/ssh/ssh_host_*"</code>
** reconfigure openssh like: <code>"#dpkg-reconfigure openssh-server"</code>
** your ssh keys should have been regenerated (even if you're on a ssh session!)
you should see an output lie:
<code>
Creating SSH2 RSA key; this may take some time ...
Creating SSH2 DSA key; this may take some time ...
* Restarting OpenBSD Secure Shell server: sshd. [OK]
</code>
source: http://www.cyberciti.biz/faq/howto-regenerate-openssh-host-keys/

Revision as of 10:18, 21 June 2010

Create virtual machines by copying a previous one

Virtual machine environments allow to create vm from scratch, of course, but it is also possible and sometimes useful to be able to create one vm as a perfect copy of another one you already have.

There are issues you have to take care of, anyway:

  • a duplicated vm will have exactly the same hostname of the original one
  • a duplicated vm will have exactly the same mac address(es) of the original one
  • a duplicated vm will have exactly the same ssh keys of the original one
  • a duplicated vm will have exactly the same SID of the original one (windows machines only)

if both the original vm and the "copy" are running together in the same network, this will cause issues and/or unsafe vm environments.

How to change vm hostname

It should be sufficient to

  • On Linux guest OSes
    • log into a vm terminal as root
    • change the /etc/hostname file content to the new hostname
    • change the /etc/hosts file content accordingly
    • reboot the vm (#reboot now)

How to change the mac address(es)

Any network card has its (supposedly) unique MAC address, you know. Virtual nics are pretty much ethe same as real, but easier to manage ;-). When you duplicate an existing vm, also its MAC address gets duplicated, and that is BAD.

Supposing your vm has only one virtual nic, you can

  • stop the vm
  • from pve web interface, remove the virtual nic (eg: eth0)
  • create a new one, this will get a new MAC, and your vm will see it always as eth0.
  • start again the vm and check if everything works fine

This is done at the host level, so is guest OS independent.

How to change the SSH keys

The SSH host keys should be unique of each machine, much like MAC address above, but for security reasons. So, after duplicating a virtual machine as a new one, you need to re.generate the vm host ssh keys.

  • ON a Linux OS
    • access a vm terminal as root
    • remove the previous keys like: "#rm /etc/ssh/ssh_host_*"
    • reconfigure openssh like: "#dpkg-reconfigure openssh-server"
    • your ssh keys should have been regenerated (even if you're on a ssh session!)

you should see an output lie: Creating SSH2 RSA key; this may take some time ... Creating SSH2 DSA key; this may take some time ...

  • Restarting OpenBSD Secure Shell server: sshd. [OK]

source: http://www.cyberciti.biz/faq/howto-regenerate-openssh-host-keys/