OpenSSH refused .ssh directory with a symbolic link

It is a permissions issue.

You need to check permissions for all directories above and including foobar's home, and also all directories above the target .ssh directory on your external device. Apart from foobar and the target .ssh directories, all others must be owned by root and not writeable by anyone else.


You may also have an SELinux issue. You can check the SELinux security context of files and directories with the -Z flag:

[sheepd0g@dogpound ~]$ ls -ZA
drwxr-xr-x. root   root   system_u:object_r:home_root_t:s0 ..
drwxrwxr-x. sheepd0g sheepd0g unconfined_u:object_r:user_home_t:s0 20170620-auditlogs
-rw-rw-r--. sheepd0g sheepd0g unconfined_u:object_r:user_home_t:s0 random.dat
drwx------. sheepd0g sheepd0g unconfined_u:object_r:ssh_home_t:s0 .ssh

A couple things to note:

  1. The period at the end of the permission mode fields means SELinux context is active for that file.
  2. Notice the Type field for the .ssh folder is different (ssh_home_t).
  3. SELinux objects, types, policies, and settings may not be the same across distributions, or even major versions. What works for RHEL6 may not for, say SUSE 10 or Debian 6 (I'm not sure Debian 6 even has SELinux enforcing, out of the box...)

Regardless, this is a good place to look if all else fails. You can check if SELinux is in enforcing mode easily enough with the following:

[sheed0g@dogpound ~]$ sudo getenforce
Enforcing

If you suspect SELinux us the issue, you can switch SELinux to Permissive mode (policies are enabled, but no action is taken -- just logging/auditing of actions):

[sheepd0b@dogpound ~]$ sudo setenforce 0
[sheepd0b@dogpound ~]$ sudo getenforce
Permissive

If your issue goes away, this is likely the problem.

Please note, there is A LOT more complexity to SELinux than what is represented here. If your .ssh/ is on an NFS share you will be required to make more changes with boolean settings for SELinux.

Here are two good references for SELinux:

CentOS wiki entry on SELinux

Red Hat Enterprise Linux 7 SELinux guide


The SSH is complaining for a reason. The ~/.ssh/ directory is world-writable and therefore anyone can modify it.

If it is not an issue for you, you can set StrictModes no in sshd_config and it will get used anyway. Don't forget to restart the sshd service after the change.