SSH git clone on Windows 10 does not work at all

SSH git clone on Windows 10 does not work at all. For three days, I’ve been at this. No answer yet. Please someone tell me what I’m doing wrong here. I need a step-by-step answer.

Windows 10
Gitea 1.50
OpenSSH and Gitea Built-in SSH servers

I’m attempting to ssh clone from Windows 10 Gitea host server to a Windows 11 client.
ssh user@host - works without using a password
ssh user@host -p 22 - works without using a password

git clone http://host-ip:3000/user/repo.git - works
git clone http://hostname:3000/user/repo.git - works

git clone git@host-ip:user/repo.git - fails
git clone git@hostname:user/repo.git -fails

In the SSH case I receive the same error message:

Cloning into ‘reponame’…
fatal: ‘‘user/reponame.git’’ does not appear to be a git repository
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

So I deleted everything to start from scratch. All repos, all .ssh key folders, all everything related to GITEA, even the GITEA entries in the Windows Credential Manager.

  1. I start by downloading GITEA 1.22.1 for Windows
  2. I run the server binary in c:\gitea
  3. I accept the default and only change the localhost to use the PC IP address
  4. I create an admin account to be the local Windows admin account (without creating a git user)
  5. GITEA server starts, OpenSSH is also started
  6. I register two gitea accounts: myname and tester
  7. I create new SSH keys for both accounts
  8. I attempt to clone using SSH as myname user but it fails

$ git clone servicename@host-ip:username/codebase.git
Cloning into ‘codebase’…
The authenticity of host ‘host-ip (host-ip)’ can’t be established.
ED25519 key fingerprint is
This key is not known by any other names.
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added ‘host-ip’ (ED25519) to the list of known hosts.
servicename@host-ip: Permission denied (publickey,keyboard-interactive).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

  1. Something came to my mind to see what would happen if I added the new SSH key into the %programdata\ssh\sshd_config\administrators_authorized_keys file from the
    ~username/.ssh/id_rsa.pub (the public key)

I then ran this test by attempting to ssh username@host-ip
I received this output to the screen

$ ssh username@host-ip
PTY allocation request failed on channel 0
Hi there, username! You’ve successfully authenticated with the key named username@host-ip, but Gitea does not provide shell access.
If this is unexpected, please log in with password and setup Gitea under another user.
Connection to laptop1 closed.

  1. Now I retry the git clone using the SSH address displayed in GITEA
    git clone servicename@host-ip:username/codebase.git

Cloning into ‘codebase’…
remote: Enumerating objects: 4, done.
remote: Counting objects: 100% (4/4), done.
remote: Compressing objects: 100% (2/2), done.
remote: Total 4 (delta 0), reused 0 (delta 0), pack-reused 0 (from 0)
Receiving objects: 100% (4/4), done.

Success!

So the solution is two things.

  1. Use the %programsdata%\ssh\sshd_config to store the key
  • make sure you set the parameters in the file to read:
    Port 22 (yes you can use the default OpenSSH default port)
    AuthorizedKeyFile = c:\programdata\ssh\administators_authorized_keys
    PasswordAuthentication no
  1. After adding (appending) the new key to the above file like so under the Windows Admin account
    % type c:\users\myname.ssh\id_rsa.pub >> %programdata\ssh\administrators_authorized_keys

Test ssh command to receive the “authentication” message.
And try the git clone again with the SSH protocol. Good luck.

This was painful…

I think you are missing the point Gitea can have a builtin ssh server on windows. It manages the authorized_keys by adding the command=“” to force it only allow gitea access. You are modifying the authorized keys yourself. I think the problem is the gitea process has no access to modify the OpenSSH on windows authorized_keys file? As SSH public keys are managed from the web gui by users…