Not able to connect to private git repo using password

28 views
Skip to first unread message

Sangeeta Saikia

unread,
Jun 3, 2021, 5:06:41 AMJun 3
to go-cd

I am trying to connect GoCD (version 21.2.0) to a git repo (version 2.25.1), and I have entered the password of the git user under the 'Advanced Settings' section. But I get Permission denied error as shown below:
 

Error performing command: --- Command ---
git ls-remote g...@xxx.xxx.xxx.xxx:sample.git refs/heads/master
--- Environment ---
{}
--- INPUT ----


--- EXIT CODE (128) ---
--- STANDARD OUT ---

--- STANDARD ERR ---
STDERR: Permission denied, please try again.
STDERR: Permission denied, please try again.
STDERR: g...@xxx.xxx.xxx.xxx: Permission denied (publickey,password).
STDERR: fatal: Could not read from remote repository.
STDERR:
STDERR: Please make sure you have the correct access rights
STDERR: and the repository exists.
---

When I run the following command from terminal, I get the prompt to enter password and the command gets executed successfully:

git ls-remote g...@xxx.xxx.xxx.xxx:sample.git refs/heads/master

What am I doing wrong? Please help.

Thanks


Marques Lee

unread,
Jun 3, 2021, 5:35:46 AMJun 3
to go...@googlegroups.com
This looks like an SSH connection string?

The credentials fields works with URLs. So, if this is SSH, you have two options. Choose one of:

1) Put the connection string in proper URL format with scheme/protocol, host, optional port, path, eg ssh://xxx.xxx.xxx.xxx/path/to/sample.git and specify creds

2) Leave the connect string as-is and use SSH key authentication. I’d highly recommend this approach over the other

--
You received this message because you are subscribed to the Google Groups "go-cd" group.
To unsubscribe from this group and stop receiving emails from it, send an email to go-cd+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/go-cd/36ff3680-fffe-406d-85b3-27d5e68b7a18n%40googlegroups.com.

Marques Lee

unread,
Jun 3, 2021, 5:40:43 AMJun 3
to go...@googlegroups.com
To elaborate on my prior answer, there are a couple of reasons why it works on the terminal and not on GoCD.

Firstly, your terminal is interactive, so git can prompt you for credentials. This will not work on GoCD because it does not open an interactive session.

Secondly, GoCD credentials are injected using a URL builder, setting the credentials as the userinfo segment (think http://user:pa...@host.tld:port/path). g...@xxx.xxx.xxx.xxx:sample.git likely won’t parse as a URL, so creds are not injected. Since there is no interactive session, auth fails.

Aravind SV

unread,
Jun 3, 2021, 5:52:50 AMJun 3
to Marques Lee, go...@googlegroups.com

I think the ssh:// protocol doesn’t work with username:password. So, I agree that option 2 (using SSH keys) is the right one to use.

Sangeeta Saikia

unread,
Jun 3, 2021, 6:04:15 AMJun 3
to go-cd
With the first approach, I get the same permission denied error. (This approach was preferred because we have some limitations in our system, and are not allowed to use public keys)

With the second approach, connection is successful.

Thank you all for the help.

Marques Lee

unread,
Jun 3, 2021, 6:18:03 AMJun 3
to Aravind SV, go...@googlegroups.com
Fair enough :). I’ve never tried it myself.

: Tyshawn: Despenza.

unread,
Aug 23, 2021, 9:13:05 PMAug 23
to go-cd
I'm having the same issue. I tried both methods and neither worked for me. It was working fine until today using HTTPS.

--- EXIT CODE (128) ---
STDERR: remote: HTTP Basic: Access denied
STDERR: fatal: Authentication failed for 

Any help would be appreciated. I'm running the latest using docker.

Reply all
Reply to author
Forward
0 new messages