I'm struggling to setup the OpenSSH on my Windows system.
I tried to follow both a system installation (like this) and a manual installation from the binaries. I copied the OpenSSH files in C:\Program Files and I installed from there.
The OpenSSH server and agent seems configured properly, but when I try to ssh to the localhost I get always the following error:
Connection reset by ::1 port 22
Hereafter some debug commands:
Get-Service ssh-agent Status Name DisplayName ------ ---- ----------- Running ssh-agent OpenSSH Authentication AgentGet-Service sshd Status Name DisplayName ------ ---- ----------- Running sshd OpenSSH SSH Servernetstat -nao | find /i '":22"' TCP 0.0.0.0:22 0.0.0.0:0 LISTENING 5680 TCP [::]:22 [::]:0 LISTENING 5680Get-NetFirewallRule -Name *OpenSSH-Server* |select Name, DisplayName, Description, Enabled Name DisplayName Description Enabled ---- ----------- ----------- ------- OpenSSH-Server-In-TCP OpenSSH Server (sshd) Truewhoami pcname\m.ceradinissh pcname\m.ceradini@localhost Connection reset by ::1 port 22
The sshd_config is the default. As suggested in other tutorial I tried also to comment the Match Group Administrators in the sshd_config, but the problem persists.
Do you have any idea of what is going on? And how I could try to fix this error of connection?
Thank you very much.
UPDATE:
I post here the answers to some of the questions and replies. Ssh to my own user is still not working.
For summarizing I did the following things:
- Uninstalled OpenSSH
- Deleted all the .ssh and Open-SSH related folders
- Installed again OpenSSH Client and Server (using the windows GUI - from settings) - and reboot
- Checked that all the SSH related commands and services works (Get-Command ssh,Get-Command sshd, Get-Command ssh-agent, Get-Service sshd, Get-Service ssh-agent)
- Create a new key for the user
- Added the public key to the authorized_keys in .ssh folder
- Commented the 'Match Group administrators' (as stated here) in sshd_config
- Enabled 'PubkeyAuthentication' in sshd_config
- Checked that sshd service are running.
debug
Get-Service sshdStatus Name DisplayName------ ---- -----------Running sshd OpenSSH SSH Server
As sshd in default configuration will not serve the loopback device,localhost as remote usually will not work, if you didn't start atunnel at that port previously:
Please execute the following command:
ssh pcname
whoamipcname\m.ceradinissh -v pcname\m.ceradiniOpenSSH_for_Windows_8.6p1, LibreSSL 3.4.3debug1: Authenticator provider $SSH_SK_PROVIDER did not resolve; disablingssh: Could not resolve hostname pcname\\m.ceradini: No such host is known.
If the host is not found use the local IP address but not the127.0.0.1 respectively not ::1
ssh -v 192.168.83.185debug1: kex: algorithm: curve25519-sha256debug1: kex: host key algorithm: ssh-ed25519debug1: kex: server->client cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: nonedebug1: kex: client->server cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: nonedebug1: expecting SSH2_MSG_KEX_ECDH_REPLYdebug1: SSH2_MSG_KEX_ECDH_REPLY receiveddebug1: Server host key: ssh-ed25519 SHA256:v7C8pJ1ci+e/ZJKhgyIvZfENRyQHd0sUJSXv8PXIEDMdebug1: load_hostkeys: fopen C:\\Users\\m.ceradini/.ssh/known_hosts2: No such file or directorydebug1: load_hostkeys: fopen __PROGRAMDATA__\\ssh/ssh_known_hosts: No such file or directorydebug1: load_hostkeys: fopen __PROGRAMDATA__\\ssh/ssh_known_hosts2: No such file or directorydebug1: Host '192.168.83.185' is known and matches the ED25519 host key.debug1: Found key in C:\\Users\\m.ceradini/.ssh/known_hosts:1debug1: rekey out after 134217728 blocksdebug1: SSH2_MSG_NEWKEYS sentdebug1: expecting SSH2_MSG_NEWKEYSdebug1: SSH2_MSG_NEWKEYS receiveddebug1: rekey in after 134217728 blocksdebug1: Will attempt key: sssapisa\\m.ceradini@TNE-Matteo ED25519 SHA256:ugTj7Iu5c0ZbiXgF6yMPO8Hru3rLp5ynP+Aku15WKX0 agentdebug1: Will attempt key: C:\\Users\\m.ceradini/.ssh/id_rsa RSA SHA256:WgcHzwF1tPBwnvdmy9KriQjn+qLuDbOhR80Bmpw10O0debug1: Will attempt key: C:\\Users\\m.ceradini/.ssh/id_dsadebug1: Will attempt key: C:\\Users\\m.ceradini/.ssh/id_ecdsadebug1: Will attempt key: C:\\Users\\m.ceradini/.ssh/id_ecdsa_skdebug1: Will attempt key: C:\\Users\\m.ceradini/.ssh/id_ed25519debug1: Will attempt key: C:\\Users\\m.ceradini/.ssh/id_ed25519_skdebug1: Will attempt key: C:\\Users\\m.ceradini/.ssh/id_xmssdebug1: SSH2_MSG_EXT_INFO receiveddebug1: 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>debug1: SSH2_MSG_SERVICE_ACCEPT receiveddebug1: Authentications that can continue: publickey,password,keyboard-interactivedebug1: Next authentication method: publickeydebug1: Offering public key: sssapisa\\m.ceradini@TNE-Matteo ED25519 SHA256:ugTj7Iu5c0ZbiXgF6yMPO8Hru3rLp5ynP+Aku15WKX0 agentdebug1: Authentications that can continue: publickey,password,keyboard-interactivedebug1: Offering public key: C:\\Users\\m.ceradini/.ssh/id_rsa RSA SHA256:WgcHzwF1tPBwnvdmy9KriQjn+qLuDbOhR80Bmpw10O0debug1: Server accepts key: C:\\Users\\m.ceradini/.ssh/id_rsa RSA SHA256:WgcHzwF1tPBwnvdmy9KriQjn+qLuDbOhR80Bmpw10O0debug1: Authentication succeeded (publickey).Authenticated to 192.168.83.185 ([192.168.83.185]:22).debug1: channel 0: new [client-session]debug1: Requesting no-more-sessions@openssh.comdebug1: Entering interactive session.debug1: pledge: filesystem fulldebug1: ENABLE_VIRTUAL_TERMINAL_INPUT is supported. Reading the VTSequence from consoledebug1: ENABLE_VIRTUAL_TERMINAL_PROCESSING is supported. Console supports the ansi parsingclient_loop: send disconnect: Connection reset
Usually you should not need to use the username, as ssh will defaultto your current user. So excluding it eliminates a source of error. —I suspect you must not use pcname\m.ceradini but only m.ceradini asusername. — But I'm not a primary windows user and currently can'tverify this.
Regarding the username I tried all the possible combinations, but the outcome is always the same.