Linux – Copy /etc/shadow to Another System and Login with Passwords

linuxpasswordshadow

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.

Best Answer

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

Related Question