3

I am asking, because I generated a live CD using the hash from an existing /etc/shadow, assuming I will then be able to login with the corresponding password, but apparently login fails.

7

It's possible if

  1. the target system uses shadow passwords, and
  2. /etc/shadow is not overridden by other mechanisms (via PAM, nss, etc.), and
  3. the target system doesn't hash /etc/shadow, and
  4. the target system has the same usernames as the source system, and
  5. the UIDs on the target system are the same as the UIDs on the source system, and
  6. the encryption methods used by the passwords need to be supported on the target system, and
  7. /etc/passwd on the target system must be in sync with the injected /etc/shadow.

I hope I didn't forget anything. :)

The easier (and safer) way to do it is to use vipw to save credentials for the relevant users on the source system, then copy them on the target system

  • Yes, the encryption methods used by the passwords need to be supported on the target system. That's unlikely to be a problem these days. – Satō Katsura Oct 30 '17 at 16:03
  • It’s implied by your #4 and #5, but it might be clearer if you explicitly said that the /etc/passwd  on the target system must be in sync with the injected /etc/shadow. – G-Man Oct 30 '17 at 17:47
  • @G-Man Edited. Now it's redundant, but oh well. :) – Satō Katsura Oct 30 '17 at 17:49
  • To move users and their passwords, I found it easiest to create them on the new system, and then grep their entries from shadow: egrep "^(jane|joe):" /etc/shadow. Then do a replace in shadow. – hschou Oct 31 '17 at 7:08
  • @SatōKatsura Since both systems are the exact same distribution, most of the requirements are definitely met. I still fail to see where things could be going wrong. All I'm doing is passwd root on the source system, then copy the second field (everything between the first and second colon) from the root: line to the corresponding line in /etc/shadow on the target system. What am I missing? – user569825 Oct 31 '17 at 8:06

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.