0

I am trying to have a git server on my raspberry pi that is passwordless with only ssh key authetication.

Sshing in with ssh key works fine, although when I try to push to a repository this is the message I get

Permission denied (publickey).
fatal: Could not read from remote repository.

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

No there is a fix to this, if in sshd_config I set:

PasswordAuthentication yes

This fixes it, although it will ask me a password

What I have done:

I have created a user git, (I tried sudo and non sudo), I have added correctly the ssh key and correctly the private key on the machine trying to push (this was verified by ssh correctly into the pi).

What has not worked: Using:

sudo passwd -d git

This will result not in a success message but in a expiring password change message, and password will still be asked making the user git unaccessible

PermitEmptyPasswords yes

Does not work

PubkeyAuthentication yes

Does not work

RSAAuthentication yes

Does not work

  • Making git sudo

Does not work

  • Adding the public ssh key and associating it with git with ssh -i

Does not work

1

As far as I understand there are two authentication systems: one for ssh and one for the git repository. As you wrote ssh authentication works but accessing git fails. You only try to fix it with settings for the ssh authentication in /etc/ssh/sshd_config but this does not effect git. You should look for settings to configure authentication on git.

6
  • How do I do that? Do you have a reference I cannot find it, I tried git-scm.com/book/en/v2/Git-on-the-Server-Setting-Up-the-Server but this does not work – Brain Bytes Oct 6 '20 at 9:48
  • That's exactly the description how to setup a git server. If it doesn't work you should ask a new question. – Ingo Oct 6 '20 at 16:35
  • look at my post, it's actually asking that question, I actually followed this to the letter – Brain Bytes Oct 6 '20 at 17:13
  • you said: You only try to fix it with settings for the ssh authentication in /etc/ssh/sshd_config but this does not effect git. You should look for settings to configure authentication on git. That page does not go over the git settings you are talking about please go more in depth if you know something – Brain Bytes Oct 6 '20 at 17:27
  • @BrainBytes At a glance I guessed that there is a mix up with the authentication for ssh and for git. To check this in detail I have to install a git server, but sorry ... I don't need a git server :-\ Try to install only the git server without ssh configured to locate the error. – Ingo Oct 6 '20 at 18:06
0

Alright this is the solution:

The git server link on the official page is not wrong, although is not really setting you up for success.

No, as someone is alluding above there is absolutely no git configuration to touch, so don't follow that path either.

  1. make 100% sure that you are all set up as passwordless
  2. Make a user for git with sudo useradd your git_user IMPORTANT: This is 90% of the solution
  3. Do not set a password
  4. Follow the directions here to make a git server and the ssh key git official setup

Set up your git server as

NOTE: Do not fully follow all instructions, do not clone or do anything else then the setup suggested and follow this guide too

  1. If you are on windows put your private ssh key generated in .ssh
  2. In powershell:
Get-Service ssh-agent

Get-Service ssh-agent | Select StartType

Get-Service -Name ssh-agent | Set-Service -StartupType Manual

Start-Service ssh-agent

ssh-add [path to your private ssh key]
  1. Clone your project or set origin (follow instructions on the link above to clone and set origin) Quick to clone command git clone

your_git_username@pi_ip_address_or_hostname:/the_git_folder_of_your_repository

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.