linux - Permission denied (publickey,gssapi-keyex,gssapi-with-mic)报错
迷茫
迷茫 2017-04-17 16:21:27
0
1
1027

1、搞了一个 VPS ,想设置免钥登录,生成私钥和公钥之后,把"#PasswordAuthentication yes" 改成"PasswordAuthentication no" 之后就一直报这个错, Permission denied (publickey,gssapi-keyex,gssapi-with-mic). 搜索了下,权限都 OK , authorized_keys 600 和 644 都试了,.ssh 也是 700 ,就是没办法啊,老报错,求高手解决;SELinux 已关闭,修改了默认端口,端口已加入防火墙了。

2、 ssh-vvv log如下:
penSSH_6.6.1, OpenSSL 1.0.1e-fips 11 Feb 2013
debug1: Reading configuration data /root/.ssh/config
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 56: Applying options for *
debug1: Connecting to 我的 IP [我的 IP] port 22.
debug1: Connection established.
debug1: permanently_set_uid: 0/0
debug1: identity file /root/.ssh/id_rsa type 1
debug1: identity file /root/.ssh/id_rsa-cert type -1
debug1: identity file /root/.ssh/id_dsa type -1
debug1: identity file /root/.ssh/id_dsa-cert type -1
debug1: identity file /root/.ssh/id_ecdsa type -1
debug1: identity file /root/.ssh/id_ecdsa-cert type -1
debug1: identity file /root/.ssh/id_ed25519 type -1
debug1: identity file /root/.ssh/id_ed25519-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_6.6.1
debug1: Remote protocol version 2.0, remote software version OpenSSH_6.6.1
debug1: match: OpenSSH_6.6.1 pat OpenSSH_6.6.1* compat 0x04000000
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-ctr hmac-md5-etm@openssh.com none
debug1: kex: client->server aes128-ctr hmac-md5-etm@openssh.com none
debug1: kex: curve25519-sha256@libssh.org need=16 dh_need=16
debug1: kex: curve25519-sha256@libssh.org need=16 dh_need=16
debug1: sending SSH2_MSG_KEX_ECDH_INIT
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: Server host key: ECDSA 7b:70:a2:01:de:01:13:68:9f:38:2a:32:11:a0:60:7e
debug1: Host ‘我的 IP' is known and matches the ECDSA host key.
debug1: Found key in /root/.ssh/known_hosts:1
debug1: ssh_ecdsa_verify: signature correct
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: gssapi-keyex
debug1: No valid Key exchange context
debug1: Next authentication method: gssapi-with-mic
debug1: Unspecified GSS failure. Minor code may provide more information
No Kerberos credentials available

debug1: Unspecified GSS failure. Minor code may provide more information
No Kerberos credentials available

debug1: Unspecified GSS failure. Minor code may provide more information

3、ls -l ~/.ssh/
显示
-rw-r--r-- 1 root root 395 12 月 6 17:31 authorized_keys
-rw-r--r-- 1 root root 139 12 月 6 17:40 config
-rw-r--r-- 1 root root 175 12 月 6 16:09 known_hosts

迷茫
迷茫

业精于勤,荒于嬉;行成于思,毁于随。

reply all(1)
迷茫

This is because you did not add the key parameter when logging in via SSH.

If you log in using a linux system, it should be like this:

MacBook-Air-Lan:~ terence$ ssh root@[host or ip] -p [your ssh port] -i [you ssh key]

-p is the port. If it is the default port 22, you can ignore this parameter;
-i is the ssh key

When generating an SSH key pair through the ssh-keygen -t rsa -b 4096 command, two files will be generated: ssh-keygen -t rsa -b 4096 命令生成SSH密钥对的时候会生成两个文件:

  1. .ssh/id_rsa.pub

  2. .ssh/id_rsa

需要将1更名为authorized_keys:

mv .ssh/id_rsa.pub .ssh/authorized_keys

然后将id_rsa文件复制到本地。

还有很重要的一点是,配置好密钥之后先尝试通过证书的方式登录,成功后再修改/etc/ssh/sshd_config

最最后,推一下我的网站,SSH的配置可以参考第七点:0x07 配置SSH

.ssh/id_rsa.pub

  1. .ssh/id_rsa

  2. Need to rename 1 to authorized_keys:

    rrreee

    Then copy the id_rsa file to local.
Another very important point is that after configuring the key, try to log in through the certificate first, and then modify /etc/ssh/sshd_config after success

Finally, push my website. For SSH configuration, please refer to point 7: 0x07 Configuring SSH🎜 🎜Preparation for newly installed centos7🎜 🎜Added: 🎜 🎜 🎜🎜Please keep the permissions of authorized_keys file to 644🎜🎜 🎜🎜Please delete the id_rsa file on the server, or set permissions to 600. 🎜🎜 🎜 🎜In addition, when logging in using an SSH key on mac or Linux, you need to set the key's permissions to 400. 🎜
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!