3

Having another Linux system mounted on /sys2. AFAIK passwords are stored there in second file of /sys2/etc/shadow file.

I'd like to set new password there. How to generate hash, which I can put there into second filed of desired row?

Btw. Is there nowadays one standard way of hashing passwords across Linux systems? I've checked on my three setups with different distributions and for same passwords I have same hashes.

P.S.

  • passwd -R /sys2 - option -R does not do the job for me. I do not have all mounts for chrooting. And system I mount is arm, and I mount it on x86.
  • passwd -r ... - I couldn't figure out how to use -r repository option to work for me.
  • The suggested answer is NOT entirely relevant. It suggests a mechanism for doing the same work manually, but that's not the only alternative. passwd supports -R CHROOT to edit the password in a different location - but it looks like adduser doesn't provide that mechanism. – Popup Oct 09 '23 at 09:29

1 Answers1

1

If you have root access on the running system (that has the /sys2 mount) then simply

chroot /sys2

And then run the passwd command for whatever user

passwd someuser

And it will let you change it as if you were running whatever system is mounted under /sys2

This of course assumes that CPU architecture isn't going to cause problems ...

ivanivan
  • 4,955
  • 1
    This only works if your architectures are the same. For instance on x86_64 and changing on an x86_64. I am still searching for a way to do this for instance if you're on your PC and you need to change a raspberry pi password. – Charles Lohr Jan 20 '22 at 04:37
  • @CharlesLohr did you find an easy way to do this between architectures? – Z4-tier Jul 26 '22 at 20:57
  • I still have not found a good way :( – Charles Lohr Jul 29 '22 at 21:02