Outils pour utilisateurs

Outils du site


tech:notes_ghost_changer_nom_ip

Différences

Ci-dessous, les différences entre deux révisions de la page.

Lien vers cette vue comparative

Les deux révisions précédentesRévision précédente
tech:notes_ghost_changer_nom_ip [2026/04/27 18:21] Jean-Baptistetech:notes_ghost_changer_nom_ip [2026/05/29 18:17] (Version actuelle) Jean-Baptiste
Ligne 1: Ligne 1:
 +<!DOCTYPE markdown>
 +{{tag>Brouillon Sécurité SSH}}
 +
 +# 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
 +~~~bash
 +subscription-manager unregister
 +subscription-manager remove --all
 +subscription-manager clean
 +~~~
 +
 +
 +
 +Hostname
 +~~~bash
 +hostnamectl set-hostname localhost.localdomain
 +~~~
 +
 +Udev
 +~~~bash
 +rm -rf /etc/udev/rules.d/70-*
 +~~~
 +
 +machine-id
 +~~~bash
 +# /var/lib/dbus/machine-id
 +#chmod 777 /etc/machine-id
 +> /etc/machine-id
 +#chmod 444 /etc/machine-id
 +~~~
 +
 +Voir aussi : 
 +  * /sys/class/dmi/id/product_uuid
 +  * /sys/class/dmi/id/product_name
 +Qui peuvent être copiés sur l'image cible pour savoir sur quel matériel l'image a été créée.
 +
 +Réseau
 +~~~bash
 +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/
 +~~~bash
 +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
 +~~~
 +
 +~~~bash
 +# Debian
 +killall dhclient
 +#rm /var/lib/dhcp/dhclient.eth0.leases
 +rm -f /var/lib/dhcp/*
 +killall ntpd
 +rm /run/ntp.conf.dhcp
 +~~~
 +
 +Autres RedHat
 +~~~bash
 +# systemctl enable initial-setup.service
 +# sys-unconfig
 +# touch /.unconfigured
 +~~~
 +
 +
 +Bash history
 +~~~bash
 +rm -f /root/.bash_history
 +rm -f /home/*/.bash_history
 +history -c && history -w
 +~~~
 +
 +Poweroff
 +~~~bash
 +poweroff
 +~~~
 +
 +
 +
 +
 +### Renommer un serveur
 +
 +~~~bash
 +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
 +
 +~~~bash
 +rm -f /etc/machine-id
 +systemd-machine-id-setup
 +~~~
 +
 +SSH
 +
 +
 +~~~bash
 +dpkg-reconfigure openssh-server
 +~~~
 +
 +Ou
 +
 +~~~bash
 +# CHANGER LE HOSTNAME AVANT !
 +
 +#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
 +
 +rm -f /etc/ssh/ssh_host_*
 +/usr/bin/ssh-keygen -A
 +~~~
 +
 +
 +~~~bash
 +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
 +
 +`/etc/resolv.conf`
 +~~~
 +#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>
  

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki