无法获得SSH公钥认证

时间:2015-01-29 19:17:19

标签: windows git ssh cygwin svc

我有一台笔记本电脑和一台基于Windows 7的远程PC,它具有静态IP(例如10.10.10.10)。我想为我的工作创建一个ssh-tunnel。所以我安装了cygwin并共享端口2222用于ssh-connection。现在,当我在sh.exe中进入我的本地PC时

ssh -v Test@10.10.10.10 -p 2222

我看到连接日志,在这个远程PC之后问我用户“测试”的密码。当我输入密码时 - 一切正常,我可以访问远程PC。

但我很懒,我不想每次都输入密码。所以,我想为这个连接创建一个ssh-keypair。为此,我进入远程主机

ssh-keygen -t dsa -b 1024

获取id_dsa& id_dsa.pub

然后我将密钥从 C:\ cygwin \ home \ Test.ssh \ id_dsa.pub 复制到 C:\ cygwin \ home \ Test.ssh \ authorized_keys ,将DSA密钥对移到我的本地PC并将它们放到我的〜/ .ssh

我也在本地〜/ .ssh / config中创建一条规则:

Host remotepc
    HostName 10.10.10.10
    Port 2222    
    IdentityFile ~/.ssh/id_dsa

现在,当我想创建与远程PC的ssh连接时

ssh -v Test@remotepc -p 2222

我看到这个日志:

OpenSSH_6.6.1, OpenSSL 1.0.1i 6 Aug 2014
debug1: Reading configuration data /c/Users/Andrey/.ssh/config
debug1: /c/Users/Andrey/.ssh/config line 5: Applying options for remotepc
debug1: Hostname has changed; re-reading configuration
debug1: Reading configuration data /c/Users/Andrey/.ssh/config
debug1: Connecting to 10.10.10.10 [10.10.10.10] port 2222.
debug1: Connection established.
debug1: identity file /c/Users/Andrey/.ssh/id_dsa type 2
debug1: identity file /c/Users/Andrey/.ssh/id_dsa-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.7
debug1: match: OpenSSH_6.7 pat OpenSSH* compat 0x04000000
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-ctr hmac-sha1-etm@openssh.com none
debug1: kex: client->server aes128-ctr hmac-sha1-etm@openssh.com none
debug1: sending SSH2_MSG_KEX_ECDH_INIT
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: Server host key: ECDSA 5a:a8:bf:df:d0:4a:ee:8c:55:29:89:80:19:41:a9:4e
debug1: Host '[10.10.10.10]:2222' is known and matches the ECDSA host key.
debug1: Found key in /c/Users/Andrey/.ssh/known_hosts:8
debug1: ssh_ecdsa_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,password,keyboard-interactive
debug1: Next authentication method: publickey
debug1: Offering DSA public key: /c/Users/Andrey/.ssh/id_dsa
Connection closed by 10.10.10.10

此后我无法访问远程PC。也许来自远程PC的sshd_config可以帮助你,你可以帮助我。

Port 2222

PubkeyAuthentication yes

UsePrivilegeSeparation yes

Subsystem   sftp    /usr/sbin/sftp-server

任何人都可以帮助我,为什么我无法连接DSA密钥对?谢谢。

1 个答案:

答案 0 :(得分:0)

我遇到了ssh的一些问题,刚解决了一个问题。这个问题略有不同,但你的问题也涉及重命名的主机,这可能是一个问题。

使用-vvv选项在3级详细模式下执行ssh,以获取最详细的调试信息。

如果没有提供更多信息,请尝试将配置文件重命名为config.backup,然后发出以下命令:

ssh -i ~/.ssh/id_dsa -v Test@10.10.10.10 -p 2222 'exit'

会话的明显突然终止可能不是这样,因此退出可能会返回ssh的错误状态。