Linux SSH Error:Permission denied (publickey,gssapi-keyex,gssapi-with-mic).
如题所示的错误,发生在Linux中通过SSH访问另一台Linux服务器的过程中;
具体现象如下所示:
1 2 3 |
[root@mysql1 ~]# ssh 192.168.27.132 Permission denied (publickey,gssapi-keyex,gssapi-with-mic). [root@mysql1 ~]# |
导致这个问题的原因是因为:
SSH服务的配置文件:/etc/ssh/sshd_config文件中的参数【PasswordAuthentication】设为了【no】
因此,解决方法是,将它改成【yes】即可。
如下的过程是我模拟上面错误呈现的时候,在目标机器【192.168.27.132】上做的操作:
从这些操作对错误的模拟过程中,你可以看到错误是怎么发生的,以及怎么做可以避免和修复错误。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
[root@mysql2 ~]# ls -ltr /etc/ssh total 604 -rw-------. 1 root root 3907 Aug 9 2019 sshd_config -rw-r--r--. 1 root root 2276 Aug 9 2019 ssh_config -rw-r--r--. 1 root root 581843 Aug 9 2019 moduli -rw-r--r--. 1 root root 382 Aug 6 14:01 ssh_host_rsa_key.pub -rw-r-----. 1 root ssh_keys 1679 Aug 6 14:01 ssh_host_rsa_key -rw-r--r--. 1 root root 162 Aug 6 14:01 ssh_host_ecdsa_key.pub -rw-r-----. 1 root ssh_keys 227 Aug 6 14:01 ssh_host_ecdsa_key -rw-r--r--. 1 root root 82 Aug 6 14:01 ssh_host_ed25519_key.pub -rw-r-----. 1 root ssh_keys 387 Aug 6 14:01 ssh_host_ed25519_key [root@mysql2 ~]# [root@mysql2 ~]# cat /etc/ssh/sshd_config | grep PermitRootLogin #PermitRootLogin yes # the setting of "PermitRootLogin without-password". [root@mysql2 ~]# [root@mysql2 ~]# cat /etc/ssh/sshd_config | grep PasswordAuthentication #PasswordAuthentication yes PasswordAuthentication yes # PasswordAuthentication. Depending on your PAM configuration, # PAM authentication, then enable this but set PasswordAuthentication [root@mysql2 ~]# [root@mysql2 ~]# sed -i '/PasswordAuthentication/s/yes/no/g' /etc/ssh/sshd_config [root@mysql2 ~]# [root@mysql2 ~]# cat /etc/ssh/sshd_config | grep PasswordAuthentication #PasswordAuthentication no PasswordAuthentication no # PasswordAuthentication. Depending on your PAM configuration, # PAM authentication, then enable this but set PasswordAuthentication [root@mysql2 ~]# [root@mysql2 ~]# service sshd status Redirecting to /bin/systemctl status sshd.service ● sshd.service - OpenSSH server daemon Loaded: loaded (/usr/lib/systemd/system/sshd.service; enabled; vendor preset: enabled) Active: active (running) since Mon 2020-09-07 23:22:18 CST; 3min 57s ago Docs: man:sshd(8) man:sshd_config(5) Main PID: 1031 (sshd) CGroup: /system.slice/sshd.service └─1031 /usr/sbin/sshd -D Sep 07 23:22:18 mysql2 systemd[1]: Starting OpenSSH server daemon... Sep 07 23:22:18 mysql2 sshd[1031]: Server listening on 0.0.0.0 port 22. Sep 07 23:22:18 mysql2 sshd[1031]: Server listening on :: port 22. Sep 07 23:22:18 mysql2 systemd[1]: Started OpenSSH server daemon. Sep 07 23:23:38 mysql2 sshd[1306]: Accepted password for root from 192.168.27.1 port 12405 ssh2 [root@mysql2 ~]# [root@mysql2 ~]# service sshd restart Redirecting to /bin/systemctl restart sshd.service [root@mysql2 ~]# |