Linux VMs Clean-up to Create OMIs
This page lists the elements of a Linux virtual machine (VM) you can clean up before creating an OUTSCALE machine image (OMI), especially if you want to share this OMI with other users or to make it public.
An OMI created from a VM or from a snapshot has the same characteristics as this VM or the VM the snapshot is created from. Moreover, a VM can contain sensitive information that you do not want to share.
It is therefore strongly recommended to clean up these elements from your VM, or the VM the snapshot is created from, before creating the OMI.
Overview
This page provides command samples for CentOS 7 VMs, but the list of elements is the same for other Linux VMs.
-
Clean the user information at the very end. To clean the information related to all users, you need to repeat the commands for each user (as explained in the page).
-
After cleaning your VM, it is recommenced to immediately stop it to create the OMI. You can then start it again if you want to keep it, but the cleanup has to be done again if you want to create another OMI.
You must execute these commands as the |
VM Configuration
Route Configuration and Network Map
Clean the route configuration and network map obtained when creating the VM:
$ /bin/rm -f /etc/sysconfig/network-scripts/{ifcfg,route}-eth[1-9]
DHCP Lease
Clean the DHCP lease that is obtained when creating the VM:
$ /bin/rm -f /var/lib/dhclient/dhclient*.lease
NTP Servers
Clean the list of NTP servers that is obtained when creating the VM:
$ sed -i '/dhclient-script/d' /etc/ntp.conf
Creation Information
Clean the information related to the first creation of the VM:
$ /bin/rm -f /var/osc/*
User
Keypairs
To clean the keypairs of the root
user, of the outscale
user, and of any other user created in the VM, use the following commands:
$ /bin/rm -f ~/.ssh/authorized_keys
$ /bin/rm -f $HOME/outscale/.ssh/authorized_keys
$ /bin/rm -f $HOME/User_Name/.ssh/authorized_keys
Once you delete the keypairs, you will not be able to reconnect to the VM after you disconnect from it at the end of this procedure. |
User Configuration Information
To clean the configuration information of the root
user, of the outscale
user, and of any other user created in the VM, use the following commands:
$ /bin/rm -f ~/.viminfo
$ /bin/rm -f $HOME/outscale/.viminfo
$ /bin/rm -f $HOME/User_Name/.viminfo