jenkinsci / jenkinsci/git-plugin
[JENKINS-40217] Git plugin can't clone when SSH Agent is enabled with different credentials
- Dominant language
- Java
- Stars
- 694
- Forks
- 1.1k
- Avg merge
- 1h 29m
- Merged PRs (30d)
- 3
Description
Hi, ...
How to replicate:
1. Create freestyle job
2. Add git scm with SSH url and select ssh key for it
3. Enable SSH Agent in Build Environment section and select different key for it
Result:
Cloning the remote Git repository
Cloning repository ssh://git@stash:7999/cm/ansible.git
> git init /opt/jenkins/workspace/ansible/cm-ansible-potiomkin-sync-34 # timeout=10
Fetching upstream changes from ssh://git@stash:7999/cm/ansible.git
> git --version # timeout=10
using GIT_SSH to set credentials jenkins at stash ssh
> git fetch --tags --progress ssh://git@stash:7999/cm/ansible.git +refs/heads/*:refs/remotes/origin/*
ERROR: Error cloning remote repo 'origin'
hudson.plugins.git.GitException: Command "git fetch --tags --progress ssh://git@stash:7999/cm/ansible.git +refs/heads/*:refs/remotes/origin/*" returned status code 128:
stdout:
stderr: Repository not found
The requested repository does not exist, or you do not have permission to access it.
fatal: Could not read from remote repository.Please make sure you have the correct access rights
Disabling SSH Agent fixes the problem.
Adding two keys to ssh agent doesn't work as expected for me. It looks like only first ssh key is used/visible.
---
Originally reported by emdepl, imported from: Git plugin can't clone when SSH Agent is enabled with different credentials
Raw content of original issue
Hi, ...
How to replicate:
1. Create freestyle job
2. Add git scm with SSH url and select ssh key for it
3. Enable SSH Agent in Build Environment section and select different key for itResult:
Cloning the remote Git repository
Cloning repository ssh://git@stash:7999/cm/ansible.git
> git init /opt/jenkins/workspace/ansible/cm-ansible-potiomkin-sync-34 # timeout=10
Fetching upstream changes from ssh://git@stash:7999/cm/ansible.git
> git --version # timeout=10
using GIT_SSH to set credentials jenkins at stash ssh
> git fetch --tags --progress ssh://git@stash:7999/cm/ansible.git +refs/heads/*:refs/remotes/origin/*
ERROR: Error cloning remote repo 'origin'
hudson.plugins.git.GitException: Command "git fetch --tags --progress ssh://git@stash:7999/cm/ansible.git +refs/heads/*:refs/remotes/origin/*" returned status code 128:
stdout:
stderr: Repository not found
The requested repository does not exist, or you do not have permission to access it.
fatal: Could not read from remote repository.Please make sure you have the correct access rights
Disabling SSH Agent fixes the problem.
Adding two keys to ssh agent doesn't work as expected for me. It looks like only first ssh key is used/visible.
environment
```
Java 1.8
Linux
Git Plugin v 3.0.0
SSH Agent Plugin v 1.13
Jenkins v 2.19
```
2 attachments
- [image-2016-12-05-10-37-34-303.png](https://issues.jenkins.io/secure/attachment/35084/image-2016-12-05-10-37-34-303.png)
> 
- [image-2016-12-05-10-38-55-269.png](https://issues.jenkins.io/secure/attachment/35083/image-2016-12-05-10-38-55-269.png)
> 
Contributor guide
Assessment
This issue has not been assessed yet.