Could not clone repository

I am really stuck with this. I have created a job in Hudson and have configured in the same way as other jobs were. My project and build deliverables exist in Git.
But every time I try to build it I am getting following errors:

Cloning repository origin
$ git clone -o origin git@github.com:xyzw/myproject.git /var/lib/hudson/jobs/myjob/workspace
ERROR: Error cloning remote repo 'origin' : Could not clone git@github.com:xyzw/myproject.git
ERROR: Cause: Error performing git clone -o origin git@github.com:xyzw/myproject.git /var/lib/hudson/jobs/myjob/workspace
Command returned status code 128: Cloning into /var/lib/hudson/jobs/myjob/workspace...
ERROR: Repository not found.
fatal: The remote end hung up unexpectedly

Trying next repository
ERROR: Could not clone repository
FATAL: Could not clone
hudson.plugins.git.GitException: Could not clone
    at hudson.plugins.git.GitSCM$2.invoke(GitSCM.java:763)
    at hudson.plugins.git.GitSCM$2.invoke(GitSCM.java:702)
    at hudson.FilePath.act(FilePath.java:756)
    at hudson.FilePath.act(FilePath.java:738)
    at hudson.plugins.git.GitSCM.checkout(GitSCM.java:702)
    at hudson.model.AbstractProject.checkout(AbstractProject.java:1181)
    at hudson.model.AbstractBuild$AbstractRunner.checkout(AbstractBuild.java:536)
    at hudson.model.AbstractBuild$AbstractRunner.run(AbstractBuild.java:424)
    at hudson.model.Run.run(Run.java:1374)
    at hudson.maven.MavenModuleSetBuild.run(MavenModuleSetBuild.java:467)
    at hudson.model.ResourceController.execute(ResourceController.java:88)
    at hudson.model.Executor.run(Executor.java:145) 

in other threads, some people recommended to create a different private-public key pair by login as a jenkins user but I dont even know how to do that in my terminal. I mean I know how to use ‘sudo’ command to login as a diffrent user but I dont think people were suggesting to do that using sudo.

  • Exclude readme from Github pull request
  • Set up new project repository on windows LAN envirnment
  • How to depend on Maven-managed project on GitHub?
  • Adding file to git's stage does nothing and cannot be committed
  • How can I stop an Xcode Archive build if my git working copy is dirty?
  • Clean up directory after GCC make
  • many thanks.

  • dokku deploy not triggering
  • git: change origin of cloned submodule
  • Invalid pathspec magic
  • How to determine if git repository is empty
  • Git: currently in merge/conflict with private remote repo. How to tell Git to just use my local files?
  • TortoiseGit: What's the difference between “Git Sync”, “Fetch” and “Pull”?
  • 2 Solutions collect form web for “Could not clone repository”

    You probably need to set up keyless ssh access from the hudson server to the git server. To do this follow these steps:

    1. Log into the hudson system as the hudson user.
    2. From the terminal window type ssh-keygen
    3. Leave the passphrase blank
    4. Provide a filename for the private and public key pairs.
    5. Log into the git system as the git user.
    6. Copy the public key from step 4 to the git system
    7. From the terminal run the following command to add the hudson public key to the git authorized keys file. cat {public key file} >> ~/.ssh/authorized_keys. You should back up the authorized_keys file first if it already exists.
    8. Test this by going back to the hudson system and attempting to ssh {git system name}. If it worked you should be able to connect without providing a password. Then attempt to clone the repository and build again.
    9. If it doesn’t work make sure to remove the key from the authorized_keys file.

    There’s a known bug around the git-plugin in Jenkins.

    https://issues.jenkins-ci.org/browse/JENKINS-24368

    The directory locations of key files above depends on whether you are using cygwin or an installed git package (i.e. c:\program files\git). Jenkins will be writing credential files and should be independent of the slave.

    Git Baby is a git and github fan, let's start git clone.