-1

At work we have a machine to which root password has been lost. I have pulled out the disk and mounted it to another computer. Now I think the next step should be editing root password in the shadow file.

But the disk I have pulled out is actually a disk1 from raid1 (mirrored) array. Is it safe to modify data on one of the disks from the array like this? If not, how should I proceed?

And if you could also answer this: what is a good way to manually generate the hash to put into the shadow file (is it md5 or something else?).

clime
  • 427
  • 1
  • 7
  • 15
  • That sounds really professional... Why haven't you simply booted with init=/bin/bash as kernel parameter? Why haven't you booted from CD? Didn't you know you have a RAID? Quite strange. – Hauke Laging Mar 01 '13 at 13:37
  • The machine (a specialized server) has no cdrom. I knew there was raid there. I can't boot with init=/bin/bash or whatever as I don't have ssh root access to it. And ye I am an amateur at this but only one that can somehow do the job atm, so please don't judge me too hard. – clime Mar 01 '13 at 13:44
  • Sounds like a maintenance nightmare. Does the server not even have a serial port? The maintenance plan can hardly be "pull out the disks". – Hauke Laging Mar 01 '13 at 14:15
  • If you don't have a CD drive in it, can you boot from a USB stick or external CD? – Sven Mar 01 '13 at 14:31
  • Well, ye I could probably boot from usb stick. It has got usb and e-sata ports. But there is no vga output or serial (it is qnap device btw), so I guess it is not a way to go. Actually the problem has shifted. I found out that password has not been lost (i am an "external employee"), it is just that admin is not allowed to ssh, which it should be. There should be sshd_config with `AllowUsers admin` but I can't find any. Thank you for the good advice below. I am still struggling how to solve this (my goal is actually to have root ssh access). – clime Mar 01 '13 at 14:40
  • This was just the most stupid stuff ever. Only thing needed was to enable ssh access via webmin. Horrible. Anyway, thanks all for the help and ideas. – clime Mar 01 '13 at 19:52

2 Answers2

3

The easiest approach would be to boot the system with a live/rescue CD which can assemble the RAID and just mount the root partition and edit the file there.

Editing just one copy of a RAID1 (and only this, not RAID 0,5 or 6) would be possible, but why bother with repairing the out-of-sync array afterwards?

Sven
  • 98,649
  • 14
  • 180
  • 226
  • I have done the thing you suggest. But I have mounted just one disk from array out of the two (mdamd -A -R). So I guess I should mount both of them and assemble the whole array, right? What would happen if I changed it on just the disk1? Will it be synced automatically or not? (sry i am noob at this) – clime Mar 01 '13 at 13:36
0

A simpler way to restore a lost root password is to boot up in single user mode. How you boot up in single user mode depends on the boot loader, and version of linux you're running.

NickW
  • 10,263
  • 1
  • 20
  • 27