Today, when setting up SSH key automatic login, I found that the message "Server refused our key" always appeared. After searching online for a long time, I found that the problem was with the permissions. Modifying the chmod permissions didn't work either. Finally, I found a method: restorecon -R -v /root/.ssh. After setting the permissions this way, I was able to log in.
restorecon, used to restore the default attributes of files/directories:
RSAAuthentication yes
PubkeyAuthentication yes
AuthorizedKeysFile .ssh/authorized_keys
PasswordAuthentication no
PermitEmptyPasswords no
2 service sshd restart
or
/etc/init.d/sshd restart
3 Set permissions:
chmod 600 /root/.ssh/authorized_keys
Add user to the su group:
Use the ordinary user "uploader" for remote management, then switch to the root user with "su root" to obtain the highest privileges
Modify ordinary user to have root privileges
1) Enter super user mode. That is, enter "su -", the system will ask for the super user password, enter the password and enter super user mode. (Of course, you can also use root directly)
2) Add write permission to the file. That is, enter the command "chmod u+w /etc/sudoers".
3) Edit the /etc/sudoers file. That is, enter the command "vim /etc/sudoers", enter "i" to enter edit mode, find this line: "root ALL=(ALL) ALL", add "xxx ALL=(ALL) ALL" below it (where xxx is your username), then save (press Esc key, then enter ":wq" to exit).
4) Revoke write permission for the file. That is, enter the command "chmod u-w /etc/sudoers".