我已经配置了 Ubuntu 10.04LTS 桌面安装以仅允许公钥认证。
结果:公钥认证完美运行!
问题:问题是,尽管配置为仅接受公钥认证,但客户端仍然接受密码验证——为什么?
当然可以使用一些建议,正如我所看到并遵循这里的建议:ssh:设置密钥后仍然可以使用密码
遵循这些建议后仍未成功:
- chmod 700 /home//.ssh
- chmod 600 /home//.ssh/authorized_keys
- 添加到/etc/ssh/ssh_config:
- 密码验证否
- ChallengeResponseAuthentication 否
- 重新启动 sshd(命令:/usr/sbin/service ssh restart)。
客户端的 /etc/ssh/ssh_config 内容如下:
# This is the ssh client system-wide configuration file. See
# ssh_config(5) for more information. This file provides defaults for
# users, and the values can be changed in per-user configuration files
# or on the command line.
# Configuration data is parsed as follows:
# 1. command line options
# 2. user-specific file
# 3. system-wide file
# Any configuration value is only changed the first time it is set.
# Thus, host-specific definitions should be at the beginning of the
# configuration file, and defaults at the end.
# Site-wide defaults for some commonly used options. For a comprehensive
# list of available options, their meanings and defaults, please see the
# ssh_config(5) man page.
Host *
# ForwardAgent no
# ForwardX11 no
# ForwardX11Trusted yes
# RhostsRSAAuthentication no
RSAAuthentication yes
PasswordAuthentication no
PermitRootLogin no
PubKeyAuthentication yes
ChallengeResponseAuthentication no
# HostbasedAuthentication no
# GSSAPIAuthentication no
# GSSAPIDelegateCredentials no
# GSSAPIKeyExchange no
# GSSAPITrustDNS no
# BatchMode no
# CheckHostIP yes
# AddressFamily any
# ConnectTimeout 0
# StrictHostKeyChecking ask
# IdentityFile ~/.ssh/identity
# IdentityFile ~/.ssh/id_rsa
# IdentityFile ~/.ssh/id_dsa
# Port 22
# Protocol 2,1
# Cipher 3des
# Ciphers aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,aes128-c bc,3des-cbc
# MACs hmac-md5,hmac-sha1,[email protected],hmac-ripemd160
# EscapeChar ~
# Tunnel no
# TunnelDevice any:any
# PermitLocalCommand no
# VisualHostKey no
SendEnv LANG LC_*
HashKnownHosts yes
GSSAPIAuthentication yes
GSSAPIDelegateCredentials no
我是不是漏掉了其他选项?也许是 Match(虽然这似乎对我没什么帮助)?
谢谢。
答案1
/etc/ssh/ssh_config
是为了客户。您想在服务器配置文件,即/etc/ssh/sshd_config
。
答案2
这条额外的线路对我来说很有用/etc/ssh/sshd_config
。
AuthenticationMethods publickey
答案3
我知道这个问题真的很老了,并且已经得到解答了,但是自从我遇到这个问题以来,这是谷歌上的第一搜索结果,我想我会把信息放在这里。
由于某种原因,在我改变之后
PasswordAuthentication yes
到
PasswordAuthentication no
在我的 sshd_config 文件中,它仍然要求输入密码。
我已经检查了这里的所有内容,并且还运行了
sudo /etc/init.d/ssh restart #or sshd
对配置文件的更改没有任何作用,所以我最终尝试重新启动机器,并且成功了。我猜 /etc/init.d/ssh 重新启动由于某种原因不起作用?无论如何,我希望这对某些人有帮助。
答案4
尝试将 PreferredAuthentications 设置为公钥。