Today, while I was setting up my SSH key login, I found this strange situation, and I copied my id_rsa.pub key content to the remote Linux host's user A. SSH under the Authorized_keys (this file I created manually) under, but when I log on again, Find that you need to enter a password, amount? It's not science! Then I looked at the remote Linux host's sshd log/var/log/secure found the following log output:
Authentication Refused:bad ownership or modes for File/home/sysadmin/.ssh/authorized_keys
It means my authorized_keys permission problem, I check the file permissions
[Root@zenoss. ssh]# ll Authorized_keys
-rw-rw-r--1 SysAdmin sysadmin 791 August 09:01 Authorized_keys
Then I looked at the Authorized_keys file permissions that other servers generated through the Ssh-copy-id command copy.
[Root@zenoss. ssh]# ll Authorized_keys
-RW-------1 SysAdmin sysadmin 393 August 09:46 Authorized_keys
Sure enough, the permissions are different, I changed the Authorized_keys file permissions to 600, and then the normal key to log in.
To find out why, I looked up the official document Http://man.openbsd.org/sshd_config found one of these configuration parameters
Strictmodes
Specifies whether sshd (8) should check file modes and ownership of the the user ' s files and
Home directory before accepting login. This is normally desirable because novices
Sometimes accidentally leave their directory or files world-writable. The default
Is "yes". This is does not apply to Chrootdirectory, whose permissions and
Ownership are checked unconditionally.
This means: sshd Check the user's home directory and file permission mode before accepting a login, you can turn off the check by setting no, but for security reasons, it is recommended that you do not change this option, and configure the home directory and file permissions are positive solutions!
The normal permissions are as follows:
[Root@zenoss home]# ls-ld sysadmin/
DRWX------. 7 sysadmin sysadmin 4096 August 09:46 sysadmin/
[Root@zenoss sysadmin]# ls-ld. ssh/
DRWX------. 2 sysadmin sysadmin 4096 August 09:46. ssh/
[Root@zenoss. ssh]# ls-l Authorized_keys
-RW-------1 SysAdmin sysadmin 393 August 09:46 Authorized_keys
Normal through the Ssh-copy-id command automatically generated Authorized_keys is 600, there will be no such problems.