During the process of setting up the server these days, I encountered a problem. The Permission of the user’s home directory: /home/user was changed to 777, so I could not log in SSH normally. The following error was reported: Permission denied (publickey,gssapi-with-mic)




SSH has strict requirements on the permission and ownership of public and private keys as follows:

  1. The following two directories must be owned by user, belong to a group of user, and have permissions of 700

\home\user

\home\user.ssh

  1. The following public key files must be owned by user, belong to user group, and have the permission of 644

\home\user.ssh\authorized_keys

  1. The ownership of the following private key file must be user, the owning group must be user, and the permission must be 600

\home\user.ssh\id_rsa




Command name for modifying permissions: chmod

The syntax is chmod ABC file

A, B, and C are digits, indicating the permissions of User, Group, and Other respectively.

R =4, w=2, x=1

  • RWX attribute 4+2+1=7;
  • Rw – attribute 4+2=6;
  • If you want the R-x attribute, 4+1=5.

For example, chmod 777 file