After configuring SSH password-free login for CentOS, you are still prompted to enter the password
Perform the following three steps to configure SSH password-less logon in CentOS:
- Generate public and private keys
- Import the public key to the authentication file and change the permission
- Test
1. Generate public and private keys
Ssh-keygen-t dsa-p'-f ~ /. Ssh/id_dsa
The default value is ~ /. Generate two files in the ssh directory:
Id_rsa: Private Key
Id_rsa.pub: Public Key
2. Import the public key to the authentication File
2.1 import Local Machine
Cat ~ /. Ssh/id_rsa.pub> ~ /. Ssh/authorized_keys
2.2 import the server for password-free Login
First, copy the authentication file to the server.
Scp ~ /. Ssh/authorized_keys xxx @ host name:/home/xxx/. ssh/
Generally, the above steps are OK, but I still need to enter the password,
Log on to the root user to view the system's log file: $ tail/var/log/secure-n 20
............
Oct 7 10:26:43 MasterServer sshd [2734]: Authentication refused: bad ownership or modes for file/home/hadoship/. ssh/authorized_keys
Oct 7 10:26:48 MasterServer sshd [2734]: Accepted password for hadoworkflow from: 1 port 37456 ssh2
Oct 7 10:26:48 MasterServer sshd [2734]: pam_unix (sshd: session): session opened for user hadoidentified by (uid = 0)
Oct 7 10:36:30 MasterServer sshd [2809]: Accepted password for hadostrap from 192.168.1.241 port 36257 ssh2
Oct 7 10:36:30 MasterServer sshd [2809]: pam_unix (sshd: session): session opened for user hadoidentified by (uid = 0)
Oct 7 10:38:28 MasterServer sshd [2857]: Authentication refused: bad ownership or modes for directory/home/hadoworkflow/. ssh
............
The prompt "/home/hadooper/. ssh" and "/home/hadoys/. ssh/authorized_keys" is incorrect. The modification is as follows:
Chmod 700 ~ /. Ssh
Chmod 600 ~ /. Ssh/authorized_keys
3. Test
Ssh host, the First Login may require yes confirmation, and then you can log on directly.
How to Improve the SSH login authentication speed of Ubuntu
Enable the SSH service to allow Android phones to remotely access Ubuntu 14.04
How to add dual authentication for SSH in Linux
Configure the SFTP environment for non-SSH users in Linux
Configure and manage the SSH service on Linux
Basic SSH tutorial
Linux SSH command instance Guide