Premise:
/etc/ssh/sshd_config configuration is correct;
Added a public key on the remote server;
The remote server SSH port is correct and is the default 22 port;
Use user name and password to login normally;
Problem:
Unable to use the public key login, each time required to enter the user name and password;
Ordinary users can log on the public key, Root does not work, but the sshd_config is allowed root landing and various configurations are correct;
When you log in, prompt as:
[Email protected]:~$ ssh egit-root
Permission denied (Publickey,gssapi-keyex,gssapi-with-mic,password)
Cause issue 1 Possible causes: File and folder permissions issues
~/.ssh/authorized_keys: This file requires a permission of 600
~/.ssh: This folder requires a permission of 700 (I ignored this permission, causing a server to never log on with the public key. Set to normal)
To avoid permission problems, we recommend that you try not to add them manually and add commands as follows:
# Generate key (you can go all the way to the prompt, see Help) Ssh-keygen-t rsa# upload public key ssh-copy-id-i ~/.ssh/id_rsa.pub [email protected]
Issue 2 possible cause: SELinux open causes
selinux Open, the normal user can log in, but Root does not allow landing
Solution: Turn off SELinux
#!/bin/bash# temporarily closed SELinux (0: off; 1: ON) Setenforce 0# permanently off SELinux (disabled: off; enforcing: ON) vi/etc/selinux/config selinux=disabled123456
Test
After the normal login statement plus-V to see the login and server Exchange details,-VV more detailed
[Email protected]:~$ ssh egit-root-v
OPENSSH_6.9P1, Libressl 2.1.8
Debug1:reading Configuration Data/users/dengqingyong/.ssh/config
DEBUG1:/users/dengqingyong/.ssh/config line 39:applying options for Egit-root
Debug1:reading Configuration Data/etc/ssh/ssh_config
DEBUG1:/etc/ssh/ssh_config line 21:applying options for *
Debug1:executing proxy command:exec ssh-q-W 192.168.1.62:22 GWe
debug1:permanently_drop_suid:502
Debug1:identity File/users/dengqingyong/.ssh/id_rsa Type 1
Debug1:key_load_public:No such file or directory
Debug1:identity File/users/dengqingyong/.ssh/id_rsa-cert type-1
debug1:enabling compatibility Mode for Protocol 2.0
Debug1:local Version string ssh-2.0-openssh_6.9
Debug1:remote Protocol version 2.0, Remote software version openssh_5.3
debug1:match:openssh_5.3 Pat openssh_5* Compat 0x0c000000
Debug1:authenticating to 192.168.1.62:22 as ' root '
Debug1:ssh2_msg_kexinit sent
Debug1:ssh2_msg_kexinit received
Debug1:kex:server->client aes128-ctr [email protected] None
Debug1:kex:client->server aes128-ctr [email protected] None
Debug1:ssh2_msg_kex_dh_gex_request (1024<3072<8192) sent
Debug1:got Ssh2_msg_kex_dh_gex_group
Debug1:ssh2_msg_kex_dh_gex_init sent
Debug1:got ssh2_msg_kex_dh_gex_reply
Debug1:server host Key:ssh-rsa Sha256:npt3kaq+nbsjgrvkutjre9aq8gcwpq1cnykdn8imkcy
Debug1:host ' 192.168.1.62 ' is known and matches the RSA Host key.
Debug1:found Key in/users/dengqingyong/.ssh/known_hosts:80
Debug1:ssh2_msg_newkeys sent
Debug1:expecting Ssh2_msg_newkeys
Debug1:ssh2_msg_newkeys received
Debug1:ssh2_msg_service_request sent
Debug1:ssh2_msg_service_accept received
Debug1:authentications that can Continue:publickey,gssapi-keyex,gssapi-with-mic,password
Debug1:next Authentication Method:publickey
debug1:offering RSA Public Key:/users/dengqingyong/.ssh/id_rsa
Debug1:authentications that can Continue:publickey,gssapi-keyex,gssapi-with-mic,password
debug1:offering RSA Public Key:
Debug1:authentications that can Continue:publickey,gssapi-keyex,gssapi-with-mic,password
Debug1:no more authentication methods to try.
Permission denied (Publickey,gssapi-keyex,gssapi-with-mic,password).
[Email protected]
Linux does not log on after configuring the public key.