I have a CentOS 7 instance on AWS, and I connect using a .pem file. When I create a new user and follow the standard steps, (create .ssh directory, chmod 700 it, create authorized_keys file, copy the public key in, chmod 600 it. Instructions here: https://aws.amazon.com/premiumsupport/knowledge-center/new-user-accounts-linux-instance/ ) It works fine.
However when I create a new user with a non-standard home directory, I keep getting a permissions error. I tried creating a folder in the / directory, then when I noticed the perms didn't match the rest of the folders there, I created a new folder there using the root account, and then created a new user underneath that. (So basically /test/ was owned by root, /test/newuser/ was owned by new user.)
I followed the rest of the steps, but still, no luck.
I checked the /etc/ssh/sshd_config file and edited to:
AuthorizedKeysFile .ssh/authorized_keys /test/newuser/.ssh/authorized_keys
That didn't work either.
I should note that this setup works fine with amazon linux 2 images, but not with CentOS 7. Any suggestions?