I recently started using TrueNAS, and I want to create separate, non-root account for data, but I’m having some problems with key authentication. Password auth works fine if I turn it on, but there’s some kind of problem with the user account reading the public key. I’ve worked with SSH keys before and I’m familiar with the usual permissions issues, but this is a new one.
The key to log into the root account works just fine, it’s only the newly created user that has problems.
I created the new account using the TrueNAS interface. Shell is set to bash for testing purposes. TrueNAS insists on creating the account only on a subdir of /mnt, so I created a new general home folder within my ZFS pool. I added the key from the UI as well. SSH client shows a permission denied error. Testing it with password, works fine. I tried the same key with the root account, worked. I checked the keyfile permissions and they’re as expected: 700 on .ssh and 600 on authorized_keys. The user owns the folders. I tried recreating the user, switching to an RSA key, no luck.
This is a new pool and I haven’t done anything exotic with file permissions (to my knowledge), ZFS or otherwise. ACL type is set to POSIX and ACL mode is set to discard. I even tried giving the home directory its own dataset. Nothing.
AppArmor is enabled but I don’t see any reference in it to SSH and I haven’t changed any of the settings.
I have two clues that lead me to believe it’s a permissions issue of SOME kind, but not a normal one. First, the contents of the auth log.
tail -f /var/log/auth.log
Feb 19 10:36:07 nas audit[12580]: USER_LOGIN pid=12580 uid=0 auid=4294967295 ses=4294967295 subj=unconfined msg='op=login acct="storage" exe="/usr/sbin/sshd" hostname=? addr=192.168.xxx.xxx terminal=sshd res=failed' Feb 19 10:36:07 truenas sshd[12580]: Could not open user 'storage' authorized keys '/mnt/pool/home/storage/.ssh/authorized_keys': Permission denied Feb 19 10:36:07 truenas sshd[12580]: Could not open user 'storage' authorized keys '/mnt/pool/home/storage/.ssh/authorized_keys2': Permission denied Feb 19 10:36:07 truenas sshd[12580]: Connection closed by authenticating user storage 192.168.xxx.xxx port 53164 [preauth] Feb 19 10:36:07 truenas audit[12580]: USER_ERR pid=12580 uid=0 auid=4294967295 ses=4294967295 subj=unconfined msg='op=PAM:bad_ident grantors=? acct="?" exe="/usr/sbin/sshd" hostname=192.168.xxx.xxx addr=192.168.xxx.xxx terminal=ssh res=failed' Feb 19 10:39:50 truenas su[12644]: (to storage) root on pts/1 Feb 19 10:39:50 truenas su[12644]: pam_unix(su:session): session opened for user storage(uid=3000) by root(uid=0) Feb 19 10:41:04 truenas su[12644]: pam_unix(su:session): session closed for user storage
It’s definitely failing to read the authorized_keys file, but I have no idea WHY. The permissions are right. I used su to log into the storage account and I can cat the file fine, so in that sense the permissions are correct… but I did notice something else odd. When I first su to the storage user, I get this error.
bash: /mnt/pool/home/storage/.bashrc: Permission denied
However it’s ONLY for this file, and I can still cat it immediately afterward. I’m wondering if a similar thing is happening with the authorized_keys file and I just can’t see it. But why would it come up with a permissions error on .bashrc and still allow me to access the file immediately afterward?
I’m a bit stumped on this one. I have a sneaking suspicion it’s related to storing the home directory on ZFS, but I really don’t know what difference it would make or how to fix it.