Reputation: 420
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 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.
Upvotes: 1
Views: 4521
Reputation: 420
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.
Upvotes: 0
Reputation: 117
git@IP_ADDRESS's means that you are connecting with "git" user not "root", does it exists in the server? The ~/.ssh/authorized_keys have to be added to the user's home.
/home/git/.ssh/authorized_keys
or in your case (Edited I was thinking in Linux :) ):
C:\Users\git\.ssh\authorized_keys
I hope it helps
Upvotes: 1