我正在尝试配置SSHD以允许在Windows Server 2012上的Cygwin下进行公钥认证。目前我的问题是访问被拒绝。我已确认我的公钥在用户的.ssh目录中的authorized_keys和authorized_keys2中保存为一行。下面你会看到我用来连接的命令,我尝试使用私钥连接SSH的详细输出,以及我的SSHD配置。我试图使用的私钥是RSA PEM格式。
我也尝试在我的配置中添加RSAAuthentication Yes,但这会导致SSHD在启动时失败。
当RSAAuthentication YES在SSHD配置中时,我得到它低于错误。
cygrunsrv: Error starting a service: QueryServiceStatus: Win32 error 1062: The service has not been started.
SSH连接命令
ssh -v -i id_rsa.pem <USER>@<SERVER ADDRESS>
SSHD配置
PasswordAuthentication no
UsePAM no
PubkeyAuthentication yes
详细输出
OpenSSH_6.2p2, OSSLShim 0.9.8r 8 Dec 2011
debug1: Reading configuration data /etc/ssh_config
debug1: /etc/ssh_config line 20: Applying options for *
debug1: /etc/ssh_config line 53: Applying options for *
debug1: Connecting to ec2-54-186-180-177.us-west-2.compute.amazonaws.com [54.186.180.177] port 22.
debug1: Connection established.
debug1: identity file id_rsa.pem type -1
debug1: identity file id_rsa.pem-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_6.2
debug1: Remote protocol version 2.0, remote software version OpenSSH_5.3
debug1: match: OpenSSH_5.3 pat OpenSSH_5*
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-ctr hmac-md5 none
debug1: kex: client->server aes128-ctr hmac-md5 none
debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(1024<1024<8192) sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_GROUP
debug1: SSH2_MSG_KEX_DH_GEX_INIT sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_REPLY
debug1: Server host key: RSA a6:a5:57:ef:09:14:7b:0b:cc:29:7b:01:fa:ac:c8:ea
debug1: Host 'ec2-54-186-180-177.us-west-2.compute.amazonaws.com' is known and matches the RSA host key.
debug1: Found key in /Users/cyotee/.ssh/known_hosts:6
Warning: the RSA host key for 'ec2-54-186-180-177.us-west-2.compute.amazonaws.com' differs from the key for the IP address '54.186.180.177'
Offending key for IP in /Users/cyotee/.ssh/known_hosts:5
Matching host key in /Users/cyotee/.ssh/known_hosts:6
Are you sure you want to continue connecting (yes/no)? yes
debug1: ssh_rsa_verify: signature correct
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: Roaming not allowed by server
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Trying private key: id_rsa.pem
debug1: read PEM private key done: type RSA
debug1: Authentications that can continue: publickey
debug1: No more authentication methods to try.
Permission denied (publickey).
你需要看一下服务器端。客户看起来运行得很好。
—
丹尼尔B
尝试检查服务器端的日志。它通常位于
—
Squeezy
/var/log/sshd.log
cygwin的内部。
sshd
并且ssh
对包含私钥的文件的权限很挑剔。它们不能是组或世界可读的。我不确定这是如何转化为Cygwin的。