无需密码即可从 Windows 10 ssh 到 Debian

无需密码即可从 Windows 10 ssh 到 Debian

我尝试从 Windows 10 客户端通过 SSH 连接到 Linux [Debian] 服务器,无需密码,并按照描述的步骤进行操作这里;但是,每次我想要登录时仍然会被要求输入密码:

  • ssh -v [email protected]
    OpenSSH_for_Windows_8.1p1, LibreSSL 3.0.2
    
    debug1: Reading configuration data C:\\Users\\user/.ssh/config
    debug1: Connecting to 192.168.137.121 [192.168.137.121] port 22.
    debug1: Connection established.
    
    debug1: identity file C:\\Users\\user/.ssh/id_rsa type 0
    debug1: identity file C:\\Users\\user/.ssh/id_rsa-cert type -1
    debug1: identity file C:\\Users\\user/.ssh/id_dsa type -1
    debug1: identity file C:\\Users\\user/.ssh/id_dsa-cert type -1
    debug1: identity file C:\\Users\\user/.ssh/id_ecdsa type -1
    debug1: identity file C:\\Users\\user/.ssh/id_ecdsa-cert type -1
    debug1: identity file C:\\Users\\user/.ssh/id_ed25519 type -1
    debug1: identity file C:\\Users\\user/.ssh/id_ed25519-cert type -1
    debug1: identity file C:\\Users\\user/.ssh/id_xmss type -1
    debug1: identity file C:\\Users\\user/.ssh/id_xmss-cert type -1
    
    debug1: Local version string SSH-2.0-OpenSSH_for_Windows_8.1
    debug1: Remote protocol version 2.0, remote software version OpenSSH_6.7p1 Debian-5+deb8u8
    debug1: match: OpenSSH_6.7p1 Debian-5+deb8u8 pat OpenSSH* compat 0x04000000
    
    debug1: Authenticating to 192.168.137.121:22 as 'root'
    debug1: SSH2_MSG_KEXINIT sent
    debug1: SSH2_MSG_KEXINIT received
    debug1: kex: algorithm: [email protected]
    debug1: kex: host key algorithm: ecdsa-sha2-nistp256
    debug1: kex: server->client cipher: [email protected] MAC: <implicit> compression: none
    debug1: kex: client->server cipher: [email protected] MAC: <implicit> compression: none
    debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
    debug1: Server host key: ecdsa-sha2-nistp256 SHA256:WCidk4fQas5o/UxDIOHdswBHGHdDZSXcySySpEm0Rp8
    debug1: Host '192.168.137.121' is known and matches the ECDSA host key.
    debug1: Found key in C:\\Users\\user/.ssh/known_hosts:1
    debug1: rekey out after 134217728 blocks
    debug1: SSH2_MSG_NEWKEYS sent
    debug1: expecting SSH2_MSG_NEWKEYS
    debug1: SSH2_MSG_NEWKEYS received
    debug1: rekey in after 134217728 blocks
    debug1: Will attempt key: C:\\Users\\user/.ssh/id_rsa RSA SHA256:9aF1rpTcWnj2ADGL/FpO0Gsgjh13zND14oRT1sfzeoU agent
    debug1: Will attempt key: C:\\Users\\user/.ssh/id_dsa
    debug1: Will attempt key: C:\\Users\\user/.ssh/id_ecdsa
    debug1: Will attempt key: C:\\Users\\user/.ssh/id_ed25519
    debug1: Will attempt key: C:\\Users\\user/.ssh/id_xmss
    debug1: SSH2_MSG_SERVICE_ACCEPT received
    debug1: Authentications that can continue: publickey,password
    
    debug1: Next authentication method: publickey
    debug1: Offering public key: C:\\Users\\user/.ssh/id_rsa RSA SHA256:9aF1rpTcWnj2ADGL/FpO0Gsgjh13zND14oRT1sfzeoU agent
    debug1: Authentications that can continue: publickey,password
    debug1: Trying private key: C:\\Users\\user/.ssh/id_dsa
    debug1: Trying private key: C:\\Users\\user/.ssh/id_ecdsa
    debug1: Trying private key: C:\\Users\\user/.ssh/id_ed25519
    debug1: Trying private key: C:\\Users\\user/.ssh/id_xmss
    
    debug1: Next authentication method: password
    debug1: read_passphrase: can't open /dev/tty: No such file or directory
    

  • ect/ssh/sshd_config
    #cat sshd_config
    # Package generated configuration file
    # See the sshd_config(5) manpage for details
    
    Port 22
    
    Protocol 2
    # HostKeys for protocol version 2
    HostKey /etc/ssh/ssh_host_rsa_key
    HostKey /etc/ssh/ssh_host_dsa_key
    HostKey /etc/ssh/ssh_host_ecdsa_key
    HostKey /etc/ssh/ssh_host_ed25519_key
    
    UsePrivilegeSeparation yes
    
    # Lifetime and size of ephemeral version 1 server key
    KeyRegenerationInterval 3600
    ServerKeyBits 1024
    
    SyslogFacility AUTH
    LogLevel INFO
    
    LoginGraceTime 120
    PermitRootLogin yes
    StrictModes yes
    
    RSAAuthentication yes
    PubkeyAuthentication yes
    #AuthorizedKeysFile     %h/.ssh/authorized_keys
    
    IgnoreRhosts yes
    RhostsRSAAuthentication no
    HostbasedAuthentication no
    #IgnoreUserKnownHosts yes
    
    PermitEmptyPasswords no
    
    ChallengeResponseAuthentication no
    
    #PasswordAuthentication yes
    
    X11Forwarding yes
    X11DisplayOffset 10
    PrintMotd no
    PrintLastLog yes
    TCPKeepAlive yes
    #UseLogin no
    
    #MaxStartups 10:30:60
    #Banner /etc/issue.net
    
    AcceptEnv LANG LC_*
    
    Subsystem sftp /usr/lib/openssh/sftp-server
    
    UsePAM yes
    

  • %UserProfile%\.ssh
    Mode                 LastWriteTime         Length Name
    ----                 -------------         ------ ----
    -a----         4/26/2022   8:59 AM            133 config
    -a----         4/20/2022   1:27 PM           2602 id_rsa
    -a----         4/20/2022   1:27 PM            569 id_rsa.pub
    -a----         4/25/2022   5:45 PM            178 known_hosts
    

  • 左边:Debian 服务器root/.ssh/id_rsa-pub
    正确的:Windows 10 客户端:~\.ssh\id_rsa.pub
    截屏

相关内容