0

I'm building my own git server on centos, I have done all these steps:

I add a new user named git and it's home is /home/git

and then I use ssh-keygen -t rsa to generate the .ssh

then I edit the /etc/ssh/sshd_config file to open the pub_key authorization :

RSAAuthentication yes
PubkeyAuthentication yes
AuthorizedKeysFile      .ssh/authorized_keys

then I git init --base in /srv/remote.git

finally I generate the id_rsa.pub on my client and copy it to my git server: /home/git/.ssh/authorized_keys

but when I git clone the repository : git@ip:/srv/remote.git

it always asks me to enter password, so why?

laoqiren
  • 3,457
  • 5
  • 19
  • 29
  • Does your ssh client use the key you authorized for the git user? As a check, you must be able to `ssh git@git_server` without a password. Try `ssh -vv -i ~/.ssh/the_generated_key.pub git@git_server` to force the use of the generated key, and to view every step of the ssh connection. – 9000 Jan 25 '17 at 03:55
  • @9000 I tried ssh git@localhost:/srv/remote.git but it comes error :Could not resolve hostname localhost:/srv/remote.git: Name or service not known – laoqiren Jan 25 '17 at 04:04
  • You need just the host part, not the path (the `:/srv/...`). It's just a regular ssh connection. – 9000 Jan 25 '17 at 04:53
  • @9000 I tried ,it asks me the password – laoqiren Jan 25 '17 at 07:19

1 Answers1

0

In order to debug what is going on:

  • check the ssh sesion on the client:

    ssh -Tv git@ip
    
  • check the logs on the server (/var/log/auth.log)

  • check also the ssh daemon session to see what it does on the server when you do the ssh from the client (stop sshd, then restart it for a one-time connection with sshd -d)
Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250