# SSH clone from a Jenkins container

**URL:** <https://community.jenkins.io/t/ssh-clone-from-a-jenkins-container/17109>\
**Category:** Using Jenkins\
**Created:** [July 16, 2024, 7:24am UTC](https://community.jenkins.io/t/ssh-clone-from-a-jenkins-container/17109 "2024-07-16T07:24:57Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rakshan](https://avatars.discourse-cdn.com/v4/letter/r/ba8739/32.png) [@Rakshan](https://community.jenkins.io/u/Rakshan)\
**Post date:** [July 16, 2024, 7:24am UTC](https://community.jenkins.io/t/ssh-clone-from-a-jenkins-container/17109/1 "2024-07-16T07:24:57Z")

</div>

Well, I have a jenkins container running on a Debian VM. We would like to explore the SSH connectivity to the GitRepositories within our container.  
Ideally, one would generate keys using ssh-keygen and copy the public key to the git repository.  
This step should be sufficient to clone the git repository and I tried it myself on the Debian VM.

However, on the jenkins container, if I do a docker exec -it _jenkinscontainerID_ /bin/bash and perform the same steps, it fails!  
I cannot clone the repository. I get the following response :

```auto
Cloning into 'TestingRepo'...
git@git.XYZ.de: Permission denied (publickey).
fatal: Could not read from remote repository.

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

```

Is there any conceptual failure in my understanding that I am missing here?

---

<div class="post-metadata">

**Author:** ![MarkEWaite](https://dub1.discourse-cdn.com/flex013/user_avatar/community.jenkins.io/markewaite/32/20_2.png) [@MarkEWaite](https://community.jenkins.io/u/MarkEWaite)\
**Post date:** [July 16, 2024, 1:21pm UTC](https://community.jenkins.io/t/ssh-clone-from-a-jenkins-container/17109/2 "2024-07-16T13:21:02Z")

</div>

> [@Rakshan](#):
>
> Is there any conceptual failure in my understanding that I am missing here?

I don’t see any conceptual failure in your understanding. It is likely a problem in your implementation. of the concept.

An [ask.ubuntu.com article](https://askubuntu.com/questions/336907/really-verbose-way-to-test-git-connection-over-ssh) suggests ways that you can use the `GIT_SSH_COMMAND` environment variable to see more detailed information about the ssh operations being performed by `git clone` over ssh. You might compare the output from the working case with the output from the non-working case to see what is different. Some of the differences might include:

- Wrong permissions on the `.ssh` directory
- Wrong permissions on the private key file in the `.ssh` directory
- Missing private key file in the `.ssh` directory
- Different `.ssh/config` settings in the two locations cause a different private key to be used
- Different network configurations in the two locations
