Maison  >  Questions et réponses  >  le corps du texte

linux - Permission denied (publickey,gssapi-keyex,gssapi-with-mic)报错

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

迷茫迷茫2744 Il y a quelques jours1041

répondre à tous(1)je répondrai

  • 迷茫

    迷茫2017-04-17 16:23:27

    这是因为你SSH登录的时候没有添加key参数。

    如果你用linux系统去登录的话应该是这样的:

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

    -p 是端口,如果是默认的22端口可以忽略这个参数;
    -i 是ssh key

    在通过 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

    新安装的centos7前期准备

    补充:

    1. 请保持authorized_keys文件的权限为644

    2. 请在服务器上删除id_rsa文件,或设置权限为600。

    另外,在mac或Linux上使用SSH密钥登录时,需要将key的权限设为400。

    répondre
    0
  • Annulerrépondre