1

I created two ssh keys for my two server.

One is Ubuntu 18.04.3 and the other is CentOS 7.7.1908.

I use putty to connect. Connection to Ubuntu was successful, but CentOS refused our key.

Centos authorized_keys had the same mode as ubuntu authorized_keys

-rw-rw-r--  1 danny danny  398  1月  8 09:52 authorized_keys

I found that CentOS needed the permissions set to 644 or 600, because in sshd_config, StrictModes default value is yes.

chmod 644 ~/.ssh/authorized_keys

but Ubuntu server didn't refused our key.

My question is two OS check file modes and ownership are different?

======= CentOS /var/log/secure==================

Jan  9 18:33:12 localhost sshd[57020]: Authentication refused: bad ownership or modes for file /home/danny/.ssh/authorized_keys

======add ls -ld / /home /home/danny /home/danny/.ssh======

Ubuntu:

danny@danny-ubuntu:~/.ssh$ ls -ld  / /home /home/danny /home/danny/.ssh
drwxr-xr-x 24 root  root  4096  1月  5 21:59 /
drwxr-xr-x  4 root  root  4096  1月  9 13:33 /home
drwxr-xr-x 22 danny danny 4096  1月  9 13:14 /home/danny
drwx------  2 danny danny 4096  1月  9 17:23 /home/danny/.ssh

CentOS:

[danny@localhost .ssh]$ ls -ld  / /home /home/danny /home/danny/.ssh
dr-xr-xr-x. 17 root  root  224  7月 29  2018 /
drwxr-xr-x.  3 root  root   19  7月 29  2018 /home
drwx------. 10 danny danny 240  1月  9 13:12 /home/danny
drwx------.  2 danny danny 150  1月  9 17:23 /home/danny/.ssh
3
  • The permissions -rw-rw-r-- are acceptable because you are the only member of the group that has read/write access. You need to look at the permissions for the directories above. Please add the result of this to your question - ls -ld / /home /home/danny /home/danny/.ssh
    – roaima
    Jan 9, 2020 at 12:27
  • Also, look in /var/log/auth.log for ssh-related failures - grep sshd /var/log/auth.log. You'll probably see the cause of the error documented (for example, Jan 9 12:33:34 centos sshd[29954]: Authentication refused: bad ownership or modes for directory /home/danny).
    – roaima
    Jan 9, 2020 at 12:34
  • Permissions for the directories above is different!!!and secure log have Authentication refused: bad ownership or modes for directory /home/danny Jan 9, 2020 at 17:39

0

You must log in to answer this question.

Browse other questions tagged .