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”.........