# Jenkins Pipeline doesn't clone private Git repository to local workspace on virtual machine

**URL:** <https://community.jenkins.io/t/jenkins-pipeline-doesnt-clone-private-git-repository-to-local-workspace-on-virtual-machine/2609>\
**Category:** Ask a question\
**Created:** [June 1, 2022, 12:09pm UTC](https://community.jenkins.io/t/jenkins-pipeline-doesnt-clone-private-git-repository-to-local-workspace-on-virtual-machine/2609 "2022-06-01T12:09:38Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![robc](https://avatars.discourse-cdn.com/v4/letter/r/e9a140/32.png) [@robc](https://community.jenkins.io/u/robc)\
**Post date:** [June 1, 2022, 12:09pm UTC](https://community.jenkins.io/t/jenkins-pipeline-doesnt-clone-private-git-repository-to-local-workspace-on-virtual-machine/2609/1 "2022-06-01T12:09:38Z")

</div>

I’m having a problem with running a Jenkins Pipeline script from SCM. Jenkins doesn’t clone the code from my private Github repository to Jenkins’ private workspace [(Console output)](https://i.stack.imgur.com/VD3Nk.png). I have a private repository on Github, from which I get the code that the pipeline has to execute. On the virtual machine on which Jenkins is installed I’ve executed the following commands to generate a SSH-keypair:

```auto
sudo su jenkins
ssh-keygen

```

I’ve added the public key to my **Github repository** under “Deploy keys” and the private key in Jenkins under Manage Jenkins → Manage Credentials → Global credentials → Add Credentials as SSH Username with private key (with “jenkins” as Username). This worked for about a week. Last monday (30/05/2022) it suddenly stopped cloning the code from my private Github repository into the local workspace of the vm, which is /var/lib/jenkins/workspace/“pipeline name”. After that I’ve tried the following:

- Revert a snapshot of the VM that was made after the installation of Ubuntu server 20.04.4 and install Java 11 and Jenkins freshly
- Remove my Github account and make a new one
- Make a new repository
- Generate new SSH-keypairs
- Use HTTPS and a Github personal access token

After this I tried to generate a new ssh-keypair using this command:

```auto
ssh-keygen -t rsa -b 4096 -C "my_email"

```

I’ve added the public key to my **Github profile** under “SSH and GPG keys” and the private key in Jenkins under Manage Jenkins → Manage Credentials → Global credentials → Add Credentials as SSH Username with private key (with my email adress of my Github profile as Username).

When I navigate to /var/lib/jenkins/workspace/“pipeline name”, a Git Clone \<-SSH url-\> **does** work and my pipeline **runs without failing**. However, this manual action is not preferred.
