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

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

迷茫
迷茫

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

全員に返信(1)
迷茫

これは、SSH 経由でログインするときに key パラメーターを追加しなかったためです。

Linux システムを使用してログインすると、次のようになります:

リーリー

-p がデフォルトのポート 22 である場合、このパラメータは無視できます。
-i は ssh キーです。

コマンドを使用して SSH キー ペアを生成すると、2 つのファイルが生成されます: ssh-keygen -t rsa -b 4096

  1. .ssh/id_rsa.pub

  2. .ssh/id_rsa

1 の名前をauthorized_keys に変更する必要があります:

リーリー

次に、id_rsa ファイルをローカルにコピーします。

もう 1 つの非常に重要な点は、キーを構成した後、最初に証明書を使用してログインを試み、成功後に証明書を変更することです

/etc/ssh/sshd_config

最後に、私の Web サイトをプッシュします。SSH 設定については、ポイント 7 を参照してください:

0x07 配置SSH

新しくインストールしたcentos7の事前準備

補足:

  1. authorized_keys ファイルの権限を 644 にしてください

  2. サーバー上の id_rsa ファイルを削除するか、権限を 600 に設定してください。

さらに、SSH キーを使用して Mac または Linux にログインする場合は、キーの権限を 400 に設定する必要があります。

いいねを押す +0
人気のチュートリアル
詳細>
最新のダウンロード
詳細>
ウェブエフェクト
公式サイト
サイト素材
フロントエンドテンプレート
私たちについて 免責事項 Sitemap
PHP中国語ウェブサイト:福祉オンライン PHP トレーニング,PHP 学習者の迅速な成長を支援します!