1

We're using git-credential-manager and connecting via SSH to a remote git repository which we host.

But every time we push/pull it still prompts for a password. Any suggestions on how to configure this correctly? Please comment if you need more information.

Global config

[credential]
    helper = 
    helper = git-credential-manager

Repository config

[remote "origin"]
    url = ssh://username@remoteip:/path/to/repository.git
    fetch = +refs/heads/*:refs/remotes/origin/*
Matthew Conradie
  • 990
  • 2
  • 8
  • 17

2 Answers2

1

The remote origin URL is an SSH one.

That means the git credential helper is not involved. At all.

What Git would ask through SSH is the passphrase of the private key or, if you do not have a registered public key in ~remoteip:/home/username/.ssh/authorized_keys, the actual password for the remote user 'username'.

The ssh-agent can help cache the passphrase.
But make sure your public key is registered on the remote machine.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
0

Thank you to VonC for pointing me in the right direction.

As he says, if using SSH, the credential manager is not used at all.

On the client run the following

ssh-keygen -t rsa

Browse to the folder where you created the key and run

ssh-add your_key_file_name

You may need to first run

start ssh-agent

to get the service running.

This creates two files in the folder you specify. Copy the contents (the public key) from the .pub file.

On the remote, paste the public key into the /home/USER/.ssh/authorized_keys file. Create the file if it doesn't exist.

This then worked for me when pushing and pulling from command line.

Matthew Conradie
  • 990
  • 2
  • 8
  • 17
  • 1
    Good feedback, well done. At the same time, you can test an HTTPS access using an HTTP URL for your remote repository. *Then* your credential helper would be useful. However, for an on-premise server, sometimes only SSH is setup to listen to remote queries. – VonC Feb 16 '23 at 09:10