...
One of the most exciting aspects of containers is being able to clone (duplicate).
Clone
Shutdown (not entirely sure if needed but I do as principle) your container and clone from the host,
Code Block | ||
---|---|---|
| ||
# clone, but you still have to manually change the host file sudo lxc-clone -o original -n new sudo sed -i 's/original/new/' /var/lib/lxc/new/rootfs/etc/hosts # update host file |
...
Clear Log Files
If you need to be enterprise class, clear out your new cloned containers log files which will reference the original container hostname. Here is an example search on a relatively new container,
Code Block | ||
---|---|---|
| ||
sudo rmsu - find /etcvar/ssh/ssh_host_* # delete original keys dpkg-reconfigure openssh-server # generate new keys |
If you chose to log in using ssh, you will want to log out and update your fingerprint file otherwise you will receive a "REMOTE HOST IDENTIFICATION HAS CHANGED!" error and not be able to ssh in. Different ways of doing this. On a Unix, Linux or Mac OS X operating system,
Code Block | ||
---|---|---|
| ||
ssh-keygen -R remote-server-name-here |
If you want to go the extra mile you might want to clear out or do a search and replace on your log files,
Code Block | ||
---|---|---|
| ||
lib/lxc/t02app/ -type f | xargs -I{} grep -li "t01app" {}
/var/lib/lxc/t02app/rootfs/var/lib/dhcp/dhclient.eth0.leases
/var/lib/lxc/t02app/rootfs/var/log/auth.log
/var/lib/lxc/t02app/rootfs/var/log/syslog.1
/var/lib/lxc/t02app/rootfs/var/log/kern.log
/var/lib/lxc/t02app/rootfs/var/log/auth.log.1
/var/lib/lxc/t02app/rootfs/var/log/syslog
/var/lib/lxc/t02app/rootfs/var/log/kern.log.1
/var/lib/lxc/t02app/rootfs/etc/ssh/ssh_host_dsa_key.pub
/var/lib/lxc/t02app/rootfs/etc/ssh/ssh_host_ed25519_key.pub
/var/lib/lxc/t02app/rootfs/etc/ssh/ssh_host_ecdsa_key.pub
/var/lib/lxc/t02app/rootfs/etc/ssh/ssh_host_rsa_key.pub |
To clear them,
Code Block |
---|
cd /var/lib/lxc/t02app/rootfs/var/log
# this does not work yet...
foreach ii ( `find . -type f` ) foreach? cp /dev/null $ii foreach? end |
Regenerate SSH Host Keys
Next boot up your container, log via the lxc console (is less steps) or ssh with a sudo enabled account and change your SSH host keys,
Code Block | ||
---|---|---|
| ||
sudo rm /etc/ssh/ssh_host_* # delete original keys
dpkg-reconfigure openssh-server # generate new keys |
If you chose to log in using ssh, you will want to log out and update your fingerprint file otherwise you will receive a "REMOTE HOST IDENTIFICATION HAS CHANGED!" error and not be able to ssh in. Different ways of doing this. On a Unix, Linux or Mac OS X operating system,
Code Block | ||
---|---|---|
| ||
ssh-keygen -R remote-server-name-here |
Share Folders with Host
... (this will be moved into a separate article)
...
How to change ssh host keys - http://www.cyberciti.biz/faq/howto-regenerate-openssh-host-keys/
Clean up log files - http://serverfault.com/questions/185253/delete-all-of-var-log