Changer le nom ou l'IP d'un serveur GNU/Linux

Template VM

Voir :

https://wiki.debian.org/HowTo/ChangeHostname

https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Virtualization/3.5/html/User_Guide/sect-Templates.html

https://access.redhat.com/documentation/en-us/red_hat_virtualization/4.0/html/virtual_machine_management_guide/chap-templates

RedHat registration

subscription-manager unregister subscription-manager remove --all subscription-manager clean

SSH

rm -rf /etc/ssh/ssh_host_*

Hostname

hostnamectl set-hostname localhost.localdomain

Udev

rm -rf /etc/udev/rules.d/70-*

machine-id

chmod 777 /etc/machine-id > /etc/machine-id chmod 444 /etc/machine-id

Voir aussi : /sys/class/dmi/id/product_uuid

Réseau

rm -f /etc/sysconfig/network-scripts/ifcfg-eth* #sed -i '/UUID/c\UUID=' /etc/sysconfig/network-scripts/ifcfg-eth0 #sed -i '/HWADDR/c\HWADDR=' /etc/sysconfig/network-scripts/ifcfg-eth0

Clean /var/log/

find /var/log/ -type f -name "*[-_]2018[0-9][1-9][0-9][1-9]*" -delete find /var/log/ -type f -name "*.old" -delete rm -rf /var/log/journal/* systemd-tmpfiles --create --prefix /var/log/journal systemctl restart systemd-journald #for fic in $(find /var/log/ -type f) ; do > $fic ; done find /var/log/ -type f -exec /bin/sh -c '>{}' \; rm /var/log/sysstat/* -rf find /var/log/ -type f -name "*.*[0-9]" -delete find /var/log/ -type f -name "*.gz" -delete
# Debian killall dhclient #rm /var/lib/dhcp/dhclient.eth0.leases rm -f /var/lib/dhcp/* killall ntpd rm /run/ntp.conf.dhcp

Autres RedHat

# systemctl enable initial-setup.service # sys-unconfig # touch /.unconfigured

Bash history

rm -f /root/.bash_history rm -f /home/*/.bash_history history -c && history -w

Poweroff

poweroff

Renommer un serveur

grep $(hostname -s) -Ril /etc/

Fichier à modifier

/etc/machine-id

/etc/hosts

/etc/hostname

/etc/mailname

/etc/exim4/update-exim4.conf.conf

/etc/machine-info

/etc/sysconfig/network

rm -f /etc/machine-id systemd-machine-id-setup
dpkg-reconfigure openssh-server

Ou

rm /etc/ssh/ssh_host_rsa_key /etc/ssh/ssh_host_rsa_key.pub rm /etc/ssh/ssh_host_dsa_key /etc/ssh/ssh_host_dsa_key.pub rm /etc/ssh/ssh_host_ecdsa_key /etc/ssh/ssh_host_ecdsa_key.pub #ssh-keygen -h -N '' -t rsa -f /etc/ssh/ssh_host_rsa_key #ssh-keygen -h -N '' -t dsa -f /etc/ssh/ssh_host_dsa_key #ssh-keygen -h -N '' -t ecdsa -f /etc/ssh/ssh_host_ecdsa_key /usr/bin/ssh-keygen -A
hostnamectl set-hostname nouveau-nom systemctl restart systemd-hostnamed

Changement d'adresse IP

Fichier à modifier

/etc/resolv.conf

/etc/systemd/resolved.conf

/etc/network/interfaces

Conf client DNS

#domain acme.local
search acme.local
options rotate timeout:1 retries:1
#options edns0
nameserver 192.168.10.253
nameserver 192.168.11.253

Avec SystemD voir /etc/systemd/resolved.conf

Généralités

Parfois il faut aussi modifier les fichiers suivants

/etc/motd

/etc/issue

Voir http://alog.ipduh.com/2014/12/clone-kvm-guest.html