我正在尝试使用ssh禁用密码身份验证,但它似乎无法正常工作。我已经按照我能找到的每一个方向来解决这个问题,而且它们基本上都是一样的。我修改了/ 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
# PubKeyAuthentication yes
# PasswordAuthentication 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-cbc,3des-cbc
# MACs hmac-md5,hmac-sha1,umac-64@openssh.com,hmac-ripemd160
# EscapeChar ~
# Tunnel no
# TunnelDevice any:any
# PermitLocalCommand no
# VisualHostKey no
# ProxyCommand ssh -q -W %h:%p gateway.example.com
# SendEnv LANG LC_*
# HashKnownHosts yes
# GSSAPIAuthentication yes
# HashKnownHosts yes
# GSSAPIAuthentication yes
# GSSAPIDelegateCredentials no
RSAAuthentication yes
PubKeyAuthentication yes
ChallengeResponseAuthentication no
PasswordAuthentication no
UsePAM no
然后我尝试重新启动服务,重新启动计算机以及我能想到的所有其他内容,但我仍然可以使用我的密码从其他多台计算机登录到此计算机。这是ssh连接的转储:
$ ssh -v matthew@server
OpenSSH_6.2p2, OSSLShim 0.9.8r 8 Dec 2011
debug1: Authentications that can continue: publickey,password
debug1: Next authentication method: publickey
debug1: Offering RSA public key: /Users/matthew/.ssh/private_key
debug1: Authentications that can continue: publickey,password
debug1: Next authentication method: password
matthew@server's password:
debug1: Authentications that can continue: publickey,password
Permission denied, please try again.
matthew@server's password:
公钥连接失败,因为我重命名了我的私钥,故意确保它强制密码验证并且理论上失败。无论如何,它没有,我不能为我的生活弄清楚我做错了什么。
有什么建议吗?
答案 0 :(得分:1)
I have modified the /etc/ssh/ssh_config files as follows...
ssh_config
是ssh 客户端的配置文件,而不是服务器。要阻止传入SSH连接上的密码身份验证,您需要禁用服务器中的功能。服务器的配置文件为sshd_config
,很可能位于/etc/ssh
目录中。
sshd_config
的手册页here.您最有可能想要设置参数
PasswordAuthentication
到“否”。