# Issue with GIT repository using ssh-keys

**URL:** <https://discourse.nodered.org/t/issue-with-git-repository-using-ssh-keys/33030>\
**Category:** General\
**Created:** [18 September 2020 09:43 UTC](https://discourse.nodered.org/t/issue-with-git-repository-using-ssh-keys/33030 "2020-09-18T09:43:16Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![crackytsi](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/crackytsi/32/28369_2.png) [@crackytsi](https://discourse.nodered.org/u/crackytsi)\
**Post date:** [18 September 2020 09:43 UTC](https://discourse.nodered.org/t/issue-with-git-repository-using-ssh-keys/33030/1 "2020-09-18T09:43:16Z")

</div>

Hi,  
I'm stuck integrating a GIT repository using ssh-keys.  
I have the NodeRed 1.1.3 (latest now) and a gitea Installation 1.12.4 (latest now)

When I try to clone a repo from the GIT server it failes.  
I'm using the GIT URL git@hostname.fqdn:gitrepo/test.git

Log from Node-Red (trace):

```auto
18 Sep 11:28:20 - [trace] runGitCommandWithSSHCommand {"key_path":"/home/wf/.node-red/projects/.sshkeys/admin_zui","passphrase":""}
18 Sep 11:28:20 - [trace] git["clone","ssh://git@hostname.fqdn:gitrepo/test.git","."]
18 Sep 11:28:20 - [debug] git -c credential.helper= clone ssh://git@hostname.fqdn:gitrepo/test.git .
18 Sep 11:28:20 - [debug] [err] Cloning into '.'...
18 Sep 11:28:20 - [debug] [err] LDAP Login enabled
18 Sep 11:28:20 - [debug] [err] Gitea: Invalid repository path
18 Sep 11:28:20 - [debug] [err] Invalid repository path: 'test.git'
18 Sep 11:28:20 - [debug] [err] fatal: Could not read from remote repository.
18 Sep 11:28:20 - [debug] [err]
18 Sep 11:28:20 - [debug] [err] Please make sure you have the correct access rights
18 Sep 11:28:20 - [debug] [err] and the repository exists.
18 Sep 11:28:20 - [debug] rc=128

```

When I try to do the same manually it works

```auto
vim /home/wf/.ssh/config
#Add the 2 lines:
---
Host hostname.fqdn
    IdentityFile /home/wf/.node-red/projects/.sshkeys/admin_zui
---

wf@hostname:/tmp/j$ git clone git@hostname.fqdn:repo/test.git
Cloning into 'test'...
LDAP Login enabled
remote: Counting objects: 3, done.
remote: Total 3 (delta 0), reused 0 (delta 0)
Receiving objects: 100% (3/3), 238 bytes | 0 bytes/s, done.
Checking connectivity... done.

```

Do you have any idear what goes wrong or how to generate more debug data?  
The following line seems a little strange, but I'm not sure.  
`git -c credential.helper= clone ssh://git@hostname.fqdn:gitrepo/test.git .`

Thanks for any hint

---

<div class="post-metadata">

**Author:** ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)\
**Post date:** [18 September 2020 09:55 UTC](https://discourse.nodered.org/t/issue-with-git-repository-using-ssh-keys/33030/2 "2020-09-18T09:55:59Z")

</div>

Try without the `ssh://` at the start of the git url when you enter it in the ui.

---

<div class="post-metadata">

**Author:** ![crackytsi](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/crackytsi/32/28369_2.png) [@crackytsi](https://discourse.nodered.org/u/crackytsi)\
**Post date:** [18 September 2020 10:41 UTC](https://discourse.nodered.org/t/issue-with-git-repository-using-ssh-keys/33030/3 "2020-09-18T10:41:00Z")

</div>

Thanks, but I tried that already,without any success/difference.

---

<div class="post-metadata">

**Author:** ![crackytsi](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/crackytsi/32/28369_2.png) [@crackytsi](https://discourse.nodered.org/u/crackytsi)\
**Post date:** [18 September 2020 11:39 UTC](https://discourse.nodered.org/t/issue-with-git-repository-using-ssh-keys/33030/4 "2020-09-18T11:39:08Z")

</div>

I can see the following log-messages in /var/log/auth.log. It seems that node-red doesn't correctly try to use key based authentication, but instead user/password.

```auto

Sep 18 13:34:40 hostname sshd[13677]: Failed password for git from 192.168.1.11 port 56653 ssh2
Sep 18 13:34:40 hostname sshd[13677]: Failed password for git from 192.168.1.11 port 56653 ssh2
Sep 18 13:34:40 hostname sshd[13677]: Connection closed by 192.168.1.11 [preauth]

```

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/4/3/4340355d69b266d057d421e1b63509d1c65dfb58.png)

---

<div class="post-metadata">

**Author:** ![crackytsi](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/crackytsi/32/28369_2.png) [@crackytsi](https://discourse.nodered.org/u/crackytsi)\
**Post date:** [28 September 2020 12:55 UTC](https://discourse.nodered.org/t/issue-with-git-repository-using-ssh-keys/33030/5 "2020-09-28T12:55:05Z")

</div>

@knolleary: Nick, can you tell me which git commands NodeRed launches? Even with all debugging enabled I can't find a reason why its failing...  
I would be very happy for any support 🙂

---

<div class="post-metadata">

**Author:** ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)\
**Post date:** [28 September 2020 13:12 UTC](https://discourse.nodered.org/t/issue-with-git-repository-using-ssh-keys/33030/6 "2020-09-28T13:12:03Z")

</div>

You can see the git commands it runs in the log -

```auto
18 Sep 11:28:20 - [trace] git["clone","ssh://git@hostname.fqdn:gitrepo/test.git","."]
18 Sep 11:28:20 - [debug] git -c credential.helper= clone ssh://git@hostname.fqdn:gitrepo/test.git .

```

---

<div class="post-metadata">

**Author:** ![crackytsi](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/crackytsi/32/28369_2.png) [@crackytsi](https://discourse.nodered.org/u/crackytsi)\
**Post date:** [28 September 2020 15:03 UTC](https://discourse.nodered.org/t/issue-with-git-repository-using-ssh-keys/33030/7 "2020-09-28T15:03:48Z")

</div>

@knolleary: Thank you 🙂 I'm totally lost to debug this issue.

> [@crackytsi](#):
>
> `git -c credential.helper= clone ssh://git@hostname.fqdn:gitrepo/test.git .`

So I'm able to authenticate using ssh-key with git by explicitly setting my project-key as key in ~/.ssh/config, otherwise it fails.  
The question is: How does this credential.helper thing work in node-red (Actually: How does node-red pass the pub-key to git).  
Is it possible. that for node-red uses the environment Variable ```  
GIT\_SSH\_COMMAND="ssh -i ~/.ssh/id\_rsa\_example"

```auto
to pass the key? Actually I'm using git < 2.3.0 and this variable is supported with git >= 2.3.0
```

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [12 October 2020 15:03 UTC](https://discourse.nodered.org/t/issue-with-git-repository-using-ssh-keys/33030/8 "2020-10-12T15:03:53Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
