簡體   English   中英

無法獲得SSH公鑰身份驗證

[英]Can't get SSH public key authentication

我有一台筆記本電腦和一台基於Windows 7的遠程PC,它們具有靜態IP(例如10.10.10.10)。 我想為我的工作創建一個ssh隧道。 所以我安裝了cygwin並共享端口2222進行ssh連接。 現在,當我在本地計算機上輸入sh.exe時

ssh -v Test@10.10.10.10 -p 2222

我看到連接日志,並且在此遠程PC詢問我輸入用戶“ Test”的密碼后。 當我輸入密碼時-沒關系,我可以訪問遠程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密鑰對? 謝謝。

我在使用ssh時遇到了一些問題,只是解決了一個。 這個問題稍有不同,但是您的還涉及到重命名的主機,這可能是一個問題。

使用-vvv選項以3級詳細模式執行ssh,以獲取最詳細的調試信息。

如果這樣不能提供更多信息,請嘗試將配置文件重命名為config.backup,然后發出以下命令:

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

會話的明顯突然終止可能不是看起來那樣,因此退出可能會返回ssh的錯誤狀態。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM