Skip to content

Instantly share code, notes, and snippets.

@lukasnellen
Last active October 13, 2020 00:15
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save lukasnellen/c090b76984fe9b4552b919b6caf18092 to your computer and use it in GitHub Desktop.
Save lukasnellen/c090b76984fe9b4552b919b6caf18092 to your computer and use it in GitHub Desktop.
How to fix Centos 7 cloud images

Centos 7 cloud image fix

The cloud images from https://cloud.centos.org/centos/7/images/ contain a /etc/resolv.conf with a spurious nameserver 10.0.2.3 entry. According to the anaconda log, this was set by DHCP during the building of the image. For most users, this entry doesn't corresponed to an existing nameserver and will slow down ssh connections, since inverse name lookups have to time out on the spurious server.

This can be fixed using virt-sysprep from libguestfs, e.g.:

virt-sysprep -a CentOS-7-x86_64-GenericCloud-1809.qcow2 --delete '/etc/resolv.conf'

You probably also want to disable the GSSAPI authentication in ssh connections, as this is another item that can cause delays opening ssh connections. The full command for that is

virt-sysprep -a CentOS-7-x86_64-GenericCloud-1809.qcow2 --delete '/etc/resolv.conf' --edit '/etc/ssh/sshd_config:s/^GSS/# GSS/'

Besides this,virt-sysprep will perform other types of cleanup, too, like the removal of log files from the installation.

For more information about virt-sysprep, consult the virt-sysprep man page.

On debian and ubuntu, you have to install the libguestfs-tools package. On CentOS 7, you have to install libguestfs-tools-c.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment