SSH key auth failure for non root user

kaledev

Cadet
Joined
Oct 8, 2021
Messages
5
I'm having an issue getting ssh keys setup so I can ssh to my TrueNAS server without a password from my local machine. It currently works perfectly if I ssh using the root user. If I attempt to use the user I was originally attempting to setup I receive the following error in /var/log/auth.log:

Authentication refused: bad ownership or modes for directory /mnt/HDD/Media

This directory is owned by my user (and all directories below it). The public key exists within the user GUI and (apparently) exists under: /mnt/HDD/Media/.ssh/authorized_keys.

I'm a bit stuck at this point so hoping someone may have experienced this or have any advice. Thanks!
 

Arwen

MVP
Joined
May 17, 2014
Messages
3,611
File permissions, ownership and group have to be "right" for SSH to allow key logins. Sounds like you have the owner and probably the group permissions correct.

But, you need permissions as follows:
  • ~/.ssh directory RWX------
  • authorized_keys file RW-------
 

kaledev

Cadet
Joined
Oct 8, 2021
Messages
5
Unfortunately that didn't work for me - I did a chmod on those two to match and I still get the same error in auth.log
File permissions, ownership and group have to be "right" for SSH to allow key logins. Sounds like you have the owner and probably the group permissions correct.

But, you need permissions as follows:
  • ~/.ssh directory RWX------
  • authorized_keys file RW-------
 

Arwen

MVP
Joined
May 17, 2014
Messages
3,611
Oh, I forgot that the parent, (aka the home directory), probably needs no group and world write permissions.

If your directory tree needs group or world write permissions, then you may want to move your HOME to a dedicated path.
 

kaledev

Cadet
Joined
Oct 8, 2021
Messages
5
Ah! - that was it. Others write on /mnt/HDD/Media was killing it. Thanks!
Oh, I forgot that the parent, (aka the home directory), probably needs no group and world write permissions.

If your directory tree needs group or world write permissions, then you may want to move your HOME to a dedicated path.
 

Arwen

MVP
Joined
May 17, 2014
Messages
3,611
Your welcome. Glad it was something straight forward.
 
Top