SSH failing authentication after manual edit of /etc/passwd and /etc/shadow

I think adding users manually to /etc/passwd and /etc/shadow is a bad idea. Those users may face troubles sooner or later. Also, you may mistype some records. I am not sure what will be the result in this case.

I recommend you to restore these files to the old state if possible and retry adding those users using useradd command.


Run pwck and grpck to check for formatting errors on the /etc/passwd and /etc/group files, respectively. This also checks the relevant shadow files.


Two possible reasons come to my mind:

  1. Your changes to /etc/passwd or /etc/shadow are somehow malformed.
  2. You forgot to change users home directory owner with chown -R user after changing their uid. File system stores uid numbers, not user names.