Ihr habt das Root Passwort eures Servers vergessen? Keinen direkten Zugriff auf den GRUB Bootloader? Mit diesen wenigen Schritten setzt ihr ein neues Root Kennwort.
Punkt 1: Recovery/Rescue starten
Startet zuerst ein Recovery/Rescue System des Hosters.
Sobald das System bereit ist, vergewissern wir uns mit fdisk -l welche Festplatten zur Verfügung stehen und beginnen entweder mit Punkt 2 oder Punkt 3.
Software-Raid
# fdisk -l
Disk /dev/sda: 2000.4 GB, 2000398934016 bytes
255 heads, 63 sectors/track, 243201 cylinders, total 3907029168 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000
Device Boot Start End Blocks Id System
/dev/sda1 * 63 195312 97625 fd Linux raid autodetect
/dev/sda2 195313 2195312 1000000 82 Linux swap / Solaris
/dev/sda3 2195313 931523437 464664062+ fd Linux raid autodetect
# cat /proc/mdstat
Personalities : [raid1]
md1 : active raid1 sdb3[1] sda3[0]
464663936 blocks [2/2] [UU]
md0 : active raid1 sda1[0] sdb1[1]
97536 blocks [2/2] [UU]
unused devices: <none>
Kein Software-Raid
# fdisk -l
Disk /dev/sda: 214.8 GB, 214752559104 bytes
16 heads, 63 sectors/track, 416109 cylinders, total 419438592 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000cd9c2
Device Boot Start End Blocks Id System
/dev/sda1 * 63 391103 195520+ 83 Linux
/dev/sda2 391104 2390975 999936 82 Linux swap / Solaris
/dev/sda3 2390976 419430399 208519712 83 Linux
Punkt 2: Root Passwort zurücksetzen (Software-Raid)
Wir führen das Software-Raid zusammen.
mdadm -As
Anschließend bauen wir eine Chroot-Umgebung auf. In diesem Beispiel ist /dev/md1 das Root-Verzeichnis und /dev/md0 das Boot-Verzeichnis.
mount /dev/md1 /mnt
mount /dev/md0 /mnt/boot
mount -t proc none /mnt/proc
mount -o bind /dev /mnt/dev
mount -o bind /sys /mnt/sys
chroot /mnt
Das Passwort kann jetzt neu gesetzt werden.
passwd
Punkt 3: Root Passwort zurücksetzen (Kein Software-Raid)
Wir beginnen mit dem Bau der Chroot-Umgebung. In diesem Beispiel ist /dev/sda3 das Root-Verzeichnis und /dev/sda1 das Boot-Verzeichnis.
mount /dev/sda3 /mnt
mount /dev/sda1 /mnt/boot
mount -t proc none /mnt/proc
mount -o bind /dev /mnt/dev
mount -o bind /sys /mnt/sys
chroot /mnt
Das Passwort kann jetzt neu gesetzt werden.
passwd
Wir beenden das Recovery/Rescue System.
Ein SSH Login mit dem neuen Passwort ist wieder möglich.