1

So I have installed and configured Openssh on windows server 2016 and now I am trying to setup passwordless connection to localhost because a scripts needs it.

Login to localhost without password is not working fine despite copying the public key to the authorized_keys file. Here's the log.

C:\Users\AWSAmazonCntAppIDDEV>ssh -vvv AWSAmazonCntAppIDDEV@localhost
OpenSSH_8.3p1, OpenSSL 1.1.1g  21 Apr 2020
debug1: Reading configuration data /etc/ssh/ssh_config
debug2: resolving "localhost" port 22
debug2: ssh_connect_direct
debug1: Connecting to localhost [::1] port 22.
debug1: Connection established.
debug1: identity file /c/Users/AWSAmazonCntAppIDDEV/.ssh/id_rsa type 0
debug1: identity file /c/Users/AWSAmazonCntAppIDDEV/.ssh/id_rsa-cert type -1
debug1: identity file /c/Users/AWSAmazonCntAppIDDEV/.ssh/id_dsa type 0
debug1: identity file /c/Users/AWSAmazonCntAppIDDEV/.ssh/id_dsa-cert type -1
debug1: identity file /c/Users/AWSAmazonCntAppIDDEV/.ssh/id_ecdsa type -1
debug1: identity file /c/Users/AWSAmazonCntAppIDDEV/.ssh/id_ecdsa-cert type -1
debug1: identity file /c/Users/AWSAmazonCntAppIDDEV/.ssh/id_ecdsa_sk type -1
debug1: identity file /c/Users/AWSAmazonCntAppIDDEV/.ssh/id_ecdsa_sk-cert type -1
debug1: identity file /c/Users/AWSAmazonCntAppIDDEV/.ssh/id_ed25519 type -1
debug1: identity file /c/Users/AWSAmazonCntAppIDDEV/.ssh/id_ed25519-cert type -1
debug1: identity file /c/Users/AWSAmazonCntAppIDDEV/.ssh/id_ed25519_sk type -1
debug1: identity file /c/Users/AWSAmazonCntAppIDDEV/.ssh/id_ed25519_sk-cert type -1
debug1: identity file /c/Users/AWSAmazonCntAppIDDEV/.ssh/id_xmss type -1
debug1: identity file /c/Users/AWSAmazonCntAppIDDEV/.ssh/id_xmss-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_8.3
debug1: Remote protocol version 2.0, remote software version OpenSSH_for_Windows_8.6
debug1: match: OpenSSH_for_Windows_8.6 pat OpenSSH* compat 0x04000000
debug2: fd 3 setting O_NONBLOCK
debug1: Authenticating to localhost:22 as 'AWSAmazonCntAppIDDEV'
debug3: hostkeys_foreach: reading file "/c/Users/AWSAmazonCntAppIDDEV/.ssh/known_hosts"
debug3: record_hostkey: found key type ECDSA in file /c/Users/AWSAmazonCntAppIDDEV/.ssh/known_hosts:1
debug3: load_hostkeys: loaded 1 keys from localhost
debug3: order_hostkeyalgs: prefer hostkeyalgs: ecdsa-sha2-nistp256-cert-v01@openssh.com,ecdsa-sha2-nistp384-cert-v01@openssh.com,ecdsa-sha2-nistp521-cert-v01@openssh.com,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521
debug3: send packet: type 20
debug1: SSH2_MSG_KEXINIT sent
debug3: receive packet: type 20
debug1: SSH2_MSG_KEXINIT received
debug2: local client KEXINIT proposal
debug2: peer server KEXINIT proposal
debug2: languages ctos:
debug2: languages stoc:
debug2: first_kex_follows 0
debug2: reserved 0
debug1: kex: algorithm: curve25519-sha256
debug1: kex: host key algorithm: ecdsa-sha2-nistp256
debug1: kex: server->client cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none
debug1: kex: client->server cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none
debug3: send packet: type 30
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug3: receive packet: type 31
debug1: Server host key: ecdsa-sha2-nistp256 SHA256:SHXUWbmljiMgQld335wbngd7Ooyvp/G8Q//6NqShdxE
debug3: hostkeys_foreach: reading file "/c/Users/AWSAmazonCntAppIDDEV/.ssh/known_hosts"
debug3: record_hostkey: found key type ECDSA in file /c/Users/AWSAmazonCntAppIDDEV/.ssh/known_hosts:1
debug3: load_hostkeys: loaded 1 keys from localhost
debug1: Host 'localhost' is known and matches the ECDSA host key.
debug1: Found key in /c/Users/AWSAmazonCntAppIDDEV/.ssh/known_hosts:1
debug3: send packet: type 21
debug2: set_newkeys: mode 1
debug1: rekey out after 134217728 blocks
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug3: receive packet: type 21
debug1: SSH2_MSG_NEWKEYS received
debug2: set_newkeys: mode 0
debug1: rekey in after 134217728 blocks
debug1: Will attempt key: /c/Users/AWSAmazonCntAppIDDEV/.ssh/id_rsa RSA SHA256:zpgLGNnEaLGE58i9zmvxJzgrI0mkxpKr6VyHH0xDvgw
debug1: Will attempt key: /c/Users/AWSAmazonCntAppIDDEV/.ssh/id_dsa RSA SHA256:zpgLGNnEaLGE58i9zmvxJzgrI0mkxpKr6VyHH0xDvgw
debug1: Will attempt key: /c/Users/AWSAmazonCntAppIDDEV/.ssh/id_ecdsa
debug1: Will attempt key: /c/Users/AWSAmazonCntAppIDDEV/.ssh/id_ecdsa_sk
debug1: Will attempt key: /c/Users/AWSAmazonCntAppIDDEV/.ssh/id_ed25519
debug1: Will attempt key: /c/Users/AWSAmazonCntAppIDDEV/.ssh/id_ed25519_sk
debug1: Will attempt key: /c/Users/AWSAmazonCntAppIDDEV/.ssh/id_xmss
debug2: pubkey_prepare: done
debug3: send packet: type 5
debug3: receive packet: type 7
debug1: SSH2_MSG_EXT_INFO received
debug1: kex_input_ext_info: server-sig-algs=<ssh-ed25519,sk-ssh-ed25519@openssh.com,ssh-rsa,rsa-sha2-256,rsa-sha2-512,ssh-dss,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,sk-ecdsa-sha2-nistp256@openssh.com,webauthn-sk-ecdsa-sha2-nistp256@openssh.com>
debug3: receive packet: type 6
debug2: service_accept: ssh-userauth
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug3: send packet: type 50
debug3: receive packet: type 51
debug1: Authentications that can continue: publickey,password,keyboard-interactive
debug3: start over, passed a different list publickey,password,keyboard-interactive
debug3: preferred publickey,keyboard-interactive,password
debug3: authmethod_lookup publickey
debug3: remaining preferred: keyboard-interactive,password
debug3: authmethod_is_enabled publickey
debug1: Next authentication method: publickey
debug1: Offering public key: /c/Users/AWSAmazonCntAppIDDEV/.ssh/id_rsa RSA SHA256:zpgLGNnEaLGE58i9zmvxJzgrI0mkxpKr6VyHH0xDvgw
debug3: send packet: type 50
debug2: we sent a publickey packet, wait for reply
debug3: receive packet: type 51
debug1: Authentications that can continue: publickey,password,keyboard-interactive
debug1: Offering public key: /c/Users/AWSAmazonCntAppIDDEV/.ssh/id_dsa RSA SHA256:zpgLGNnEaLGE58i9zmvxJzgrI0mkxpKr6VyHH0xDvgw
debug3: send packet: type 50
debug2: we sent a publickey packet, wait for reply
debug3: receive packet: type 51
debug1: Authentications that can continue: publickey,password,keyboard-interactive
debug1: Trying private key: /c/Users/AWSAmazonCntAppIDDEV/.ssh/id_ecdsa
debug3: no such identity: /c/Users/AWSAmazonCntAppIDDEV/.ssh/id_ecdsa: No such file or directory
debug1: Trying private key: /c/Users/AWSAmazonCntAppIDDEV/.ssh/id_ecdsa_sk
debug3: no such identity: /c/Users/AWSAmazonCntAppIDDEV/.ssh/id_ecdsa_sk: No such file or directory
debug1: Trying private key: /c/Users/AWSAmazonCntAppIDDEV/.ssh/id_ed25519
debug3: no such identity: /c/Users/AWSAmazonCntAppIDDEV/.ssh/id_ed25519: No such file or directory
debug1: Trying private key: /c/Users/AWSAmazonCntAppIDDEV/.ssh/id_ed25519_sk
debug3: no such identity: /c/Users/AWSAmazonCntAppIDDEV/.ssh/id_ed25519_sk: No such file or directory
debug1: Trying private key: /c/Users/AWSAmazonCntAppIDDEV/.ssh/id_xmss
debug3: no such identity: /c/Users/AWSAmazonCntAppIDDEV/.ssh/id_xmss: No such file or directory
debug2: we did not send a packet, disable method
debug3: authmethod_lookup keyboard-interactive
debug3: remaining preferred: password
debug3: authmethod_is_enabled keyboard-interactive
debug1: Next authentication method: keyboard-interactive
debug2: userauth_kbdint
debug3: send packet: type 50
debug2: we sent a keyboard-interactive packet, wait for reply
debug3: receive packet: type 51
debug1: Authentications that can continue: publickey,password,keyboard-interactive
debug3: userauth_kbdint: disable: no info_req_seen
debug2: we did not send a packet, disable method
debug3: authmethod_lookup password
debug3: remaining preferred:
debug3: authmethod_is_enabled password
debug1: Next authentication method: password
AWSAmazonCntAppIDDEV@localhost's password:

Here's what I tried so far:

  • Commented below lines in sshd_config file
#Match Group administrators
#       AuthorizedKeysFile __PROGRAMDATA__/ssh/administrators_authorized_keys
  • PubkeyAuthentication and PasswordAuthentication are set to yes
 PubkeyAuthentication yes
 PasswordAuthentication yes

  • The %user_home/.ssh folder is only owned by system and my_ID (my account). Also inheritance is disabled. This is to make sure that .ssh folder has equivalent 700 permissions and authorized_keys file has 0600 permissions.
  • Tried to recreate keys.

I still think its a permission issue because when I run ls -lart in windows its still showing the permissions as 644, as you can see. I tried to change it to 600 but its not letting me because its windows. I'd appreciate any help on this.

C:\Users\AWSAmazonCntAppIDDEV\.ssh>ls -alrt
total 26
-rw-r--r-- 1 AWSAmazonCntAppIDDEV 1049089  589 Jul 15 14:01 id_rsa.pub
-rw-r--r-- 1 AWSAmazonCntAppIDDEV 1049089 2635 Jul 15 14:01 id_dsa
-rw-r--r-- 1 AWSAmazonCntAppIDDEV 1049089  588 Jul 15 14:02 authorized_keys
-rw-r--r-- 1 AWSAmazonCntAppIDDEV 1049089  171 Jul 15 14:05 known_hosts
drwxr-xr-x 1 AWSAmazonCntAppIDDEV 1049089    0 Jul 15 14:23 ..
drwxr-xr-x 1 AWSAmazonCntAppIDDEV 1049089    0 Jul 15 14:39 .
3
  • 1
    What syntax are you using to connect? Does it have AWSAmazonCntAppIDDEV in it? Edit your question
    – Ramhound
    Jul 16, 2021 at 17:49
  • It has. Just edited the question.
    – tarun
    Jul 16, 2021 at 18:36
  • You haven’t provided what I asked for by the way. Verify each of the keys actually exists and are owned and accessible by only AWSAmazonCntAppIDDEV
    – Ramhound
    Jul 16, 2021 at 21:03

1 Answer 1

0

I uninstalled openssh and reinstalled it using steps mentioned in the below document. Then I was able ssh to localhost without password.

https://adamtheautomator.com/openssh-windows/

I skipped the certificate Authentication section in the link, as it was irrelevant in my case.

1
  • Welcome to Super User! Please quote the essential parts of the answer from the reference link(s), as the answer can become invalid if the linked page(s) change.
    – DavidPostill
    Jul 20, 2021 at 14:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.