Issue
I have a VPS (Windows Server 2016) and ran a SSH server on it with OpenSSH for windows. I would run a git server on this VPS so i searched for some tutorials in google and found href="https://github.com/PowerShell/Win32-OpenSSH/wiki/Setting-up-a-Git-server-on-Windows-using-Git-for-Windows-and-Win32_OpenSSH" rel="nofollow noreferrer">this.
The tutorial for configuring the server side settings is okay and i created a bare git repository. I would connect to the git server with my own computer using SSH public key, but it wants password from me! I tried to save my public generated key from my own PC (without passphrase) in /.ssh/authorized_keys file in server but it didn't worked. When i use this git clone user@IP_ADDRESS:<repo dir>
command to clone the existing repository from the server it keeps telling me that i should enter a password:
Cloning into 'central'...
user@IP_ADDRESS's password:
I tried to skip the password prompt by just pressing the enter also tried root for password but it didn't help anyway.
Although i used ssh -Tv git@IP_ADDRESS
to see step by step what is happening then i realized that the publickey
authentication getting skipped and process goes for password
auth method.
Solution
Actually the problem was about the privileges of current user group on the server. In my case that user has administrator privileges so the SSH would search in the %PROGRAMDATA%/ssh/administrator_authorized_keys
for the public keys. For normal user accounts in Windows, SSH automatically would go for /users/{username}/.ssh/authorized_keys
file where i was copying my machine public SSH key. So i moved my public key to the administrator_authorized_keys
file and everything works fine now.
Thanks to @EdKenbers for replying.
Answered By - Alireza Kiani Answer Checked By - Marilyn (WPSolving Volunteer)