SSH Authentication refused: bad ownership or modes for file /home/user/.ssh/authorized_keys2

I‘m trying to login using ssh keys but server is only allows to login me using a password. The following message is logged into server /var/log/secure file:

ADVERTISEMENTS

Feb 25 06:36:50 ns5 sshd[26681]: Authentication refused: bad ownership or modes for file /home/user/.ssh/authorized_keys2

How do I fix this problem?

You need to set correct permission on server. Login to your account using passwod. Once logged in type the following command to fix this issue:
chmod 0644 ~/.ssh/authorized_keys2
Now, you should able to login using ssh keys from your workstation or other servers.

🐧 Get the latest tutorials on SysAdmin, Linux/Unix, Open Source/DevOps topics:
CategoryList of Unix and Linux commands
File Managementcat
FirewallCentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network Utilitiesdig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg jobs killall kill pidof pstree pwdx time
Searchinggrep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNCentOS 8 Debian 10 Firewall Ubuntu 20.04

ADVERTISEMENTS
1 comment… add one
  • ismael silva Jan 11, 2012 @ 21:57

    Set the correct permission from home directory user…
    this will to be. “755”.

Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre>, <code>...</code> and <kbd>...</kbd> for code samples.