We have a problem on a centos 6 server. normally, PasswordAuthentication is off.

When I get connected using rescue mode, I execute these commands :

mount -o remount,rw /
chroot / /bin/bash
passwd root

It says password reset successfully.

And I also try to edit /etc/ssh/sshd_config and/etc/ssh/ssh_config to enable password authentication, but the problem is that none of the modifications is saved after reboot. And when I try the new password with ssh, it does not work.

Do you have any idea?

  • Thank you so much for your answer , it was of great help. ^^
    – SmootQ
    Oct 29 '18 at 14:53

You are editing the live version of the rescue filesystem and not your mounted disk, hence the modifications not appearing.

The chroot should point to a valid mount point.

You might also want to build a /mnt point properly before the chroot

As in:

mkdir /mnt2
mount /device_to_my_root_disk /mnt2
cd /mnt2
mount -o bind /proc proc
mount -o bind /dev dev
mount -o bind /sys sys
chroot /mnt2

Beware that if you have /usr on separate filesystems, you would be better mount it on top of /mnt2 before the chroot (and if you want to install extra packages, you need at least also /var ).

Having /proc, /sys, and /dev is not essential for some commands, however it allows to use Linux commands that depend on them, and feel more at home.

If you have LVM, you also have to do vgchange -ay to activate the LVM Volume groups in order to be able to mount your partitions.

See related question in our sister site SuperUser : mount dev, proc, sys in a chroot environment?

  • Thank you so much for your reply, I will try this solution, I remember this morning I tried to mount one of the disks on /mnt, and it says : uknown filesystem type linux_raid_member
    – SmootQ
    Oct 29 '18 at 14:39
  • 2
    @SmootQ that's fortunate. If you'd been able to continue with that you would have introduced corruption into the filesystem hosted on that RAID member.
    – roaima
    Oct 29 '18 at 14:45
  • So, I was lucky with that, thank you so much for your help ^^
    – SmootQ
    Oct 29 '18 at 14:52
  • You are welcome, congrats. Oct 29 '18 at 15:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.