Password is still required after authorized_keys is configured for ssh

Source: Internet
Author: User
When we set up Hadoop a few times ago, we configured the ssh public key of the local machine (localhost) to the authorized_keys file. However, when we connect to localhost via ssh, we still prompt that we need to enter the password. later we found that it was $ HOME /. ssh/authorized_keys. The reason is that users outside the owner cannot have the write permission on the authorized_keys file. otherwise, sshd will not allow this file because it may be tampered with by other users.

When we set up Hadoop a few times ago, we configured the ssh public key of the local machine (localhost) to the authorized_keys file. However, when we connect to localhost via ssh, we still prompt that we need to enter the password. later we found that it was $ HOME /. ssh/authorized_keys. The reason is that users outside the owner cannot have the write permission on the authorized_keys file. otherwise, sshd cannot use the file because it may be tampered with by other users.
The command line is as follows:

[Hadoop @ guest1 ~] $ Cd. ssh/[hadoop @ guest1. ssh] $ lltotal 16-rw-r -- 1 hadoop 395 Jan 1218:37 authorized_keys-rw ------- 1 hadoop 1675 Jan 1218:36 id_rsa-rw-r -- r -- 1 hadoop 395 Jan 1218:36 id_rsa.pub-rw-r -- r -- 1 hadoop 796 Jan 6 08:40 known_hosts # note the authorized_keys file permission; the key in the file does not work. # Use chmod to modify the authorized_keys file permission [hadoop @ guest1. ssh] $ chmod g-w authorized_keys [hadoop @ guest1. ssh] $ lltotal 16-rw-r -- r -- 1 hadoop 395 Jan 1218:37 authorized_keys-rw ------- 1 hadoop 1675 Jan 1218:36 id_rsa-rw-r -- r -- 1 hadoop 395 Jan 1218:36 id_rsa.pub-rw-r -- r -- 1 hadoop 796 jan 6 known_hosts # After modification, sshd can normally use the authorized_keys file [hadoop @ guest1 ~] $ Ssh localhostLast login: Sat Jan 1218:40:332013 from localhost [hadoop @ guest1 ~] $ ExitlogoutConnection to localhost closed. [hadoop @ guest1 ~] $


Later, I checked in detail. if the authorized_keys file, the $ HOME/. ssh directory, or the $ HOME directory give users outside of this user the write permission, sshd will reject ~ The key in the/. ssh/authorized_keys file for authentication.
Run the "man sshd" command to view the description of the authorized_keys file as follows:

man sshd.....     ~/.ssh/authorized_keys             Lists the public keys (DSA/ECDSA/RSA) that can be used for logging in as this user.  The format of             this file is described above.  The content of the file is not highly sensitive, but the recommended             permissions are read/write for the user, and not accessible by others.                 If this file, the ~/.ssh directory, or the user's home directory are writable by other users, then the             file could be modified or replaced by unauthorized users.  In this case, sshd will not allow it to be             used unless the StrictModes option has been set to “no”.........


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.