Answers: <p>Hello guys I have found the solution, 
  So I create ssh keys from my <strong>Jenkins Server</strong>, and then called the private key from my code, this is how it looks like on my project structure:</p>
  
  <pre><code>root@staging:~/project# tree
  .
  ├── deployment.yaml
  ├── server
  │   └── host
  └── the_private_key
  
  1 directory, 3 files
  </code></pre>
  
  <p>and my deployment.yaml:</p>
  
  <pre><code>---
  - hosts: staging
    become_user: sudo
    tasks:
    - name: populate my project
      git: repo=git@bitbucket.org:source/source.git
           version=master
           dest=/var/www/test/
           key_file=the_private_key
           accept_hostkey=yes
  </code></pre>
  
  <p>And then I copied <strong>Jenkins Server</strong> public key to <strong>Target Server</strong>, then everything worked well</p>
  
Answers: CC BY-SA 3.0
Answers: 2017-08-31T10:15:58.537Z
Answers: 2017-08-31T10:15:58.537Z
Answers: spacetrack
Answers: <p>First make sure that you added the public key to the right repo with the right permission, usually I add it to 'Access keys' so the user has read only permission, then to make sure that is working add the private key to you system so you can use it with using git:</p>
  
  <pre><code>ssh-add private-key
  git clone &lt;your git repo&gt;
  </code></pre>
  
  <p>If it's working, add those credential to you jenkins and use them later </p>
  
Answers: CC BY-SA 3.0
Answers: 2017-08-29T06:29:08.010Z
Answers: as you can see above I have add the public key to 'Access Key' and the deployment key has read access to the repo, but still I got the same error
Answers: spacetrack
Answers: CC BY-SA 3.0
Answers: 2017-08-29T04:54:40.460Z
Answers: 2017-08-29T04:54:40.460Z
Answers: Wissam Roujoulah
Body: <p>Using jenkins to pull from bitbucket repository, I got this error:</p>
  <blockquote>
  <p>git@bitbucket.org:source/source.git +refs/heads/<em>:refs/remotes/origin/</em>&quot; returned status code 128:
  stdout:
  stderr: repository access denied. deployment key is not associated with the requested repository.
  fatal: Could not read from remote repository.</p>
  </blockquote>
  <p>I have added ssh keys in the bitbucket repo, I have run ssh -v git@bitbucket.org and this is the output:</p>
  <blockquote>
  <p>authenticated via a deploy key.</p>
  <p>You can use git or hg to connect to Bitbucket. Shell access is disabled.</p>
  <p>This deploy key has read access to the following repositories:</p>
  <p>source/source: root.staging_quc -- root@QUICKRESPONSE
  debug1: channel 0: free: client-session, nchannels 1
  Connection to bitbucket.org closed.
  Transferred: sent 2968, received 1872 bytes, in 0.0 seconds
  Bytes per second: sent 82471.7, received 52017.2
  debug1: Exit status 0</p>
  </blockquote>
  <p>I don't really know what to do, hope you guys have any clue on this one I will update this question</p>
  
Tags: <jenkins><bitbucket>
Title: Jenkins deployment key is not associated with the repository
UserDisplayName: spacetrack
ThreadText: # Jenkins deployment key is not associated with the repository
  
  (Asked by: username_0 on 2017-08-29)
  
  Using jenkins to pull from bitbucket repository, I got this error:
  
  > git@bitbucket.org:source/source.git +refs/heads/*:refs/remotes/origin/*" returned status code 128:
  > stdout:
  > stderr: repository access denied. deployment key is not associated with the requested repository.
  > fatal: Could not read from remote repository.
  
  I have added ssh keys in the bitbucket repo, I have run ssh -v git@bitbucket.org and this is the output:
  
  > authenticated via a deploy key.
  >
  > You can use git or hg to connect to Bitbucket. Shell access is disabled.
  >
  > This deploy key has read access to the following repositories:
  >
  > source/source: root.staging\_quc -- root@QUICKRESPONSE
  > debug1: channel 0: free: client-session, nchannels 1
  > Connection to bitbucket.org closed.
  > Transferred: sent 2968, received 1872 bytes, in 0.0 seconds
  > Bytes per second: sent 82471.7, received 52017.2
  > debug1: Exit status 0
  
  I don't really know what to do, hope you guys have any clue on this one I will update this question
  
  **Tags:** jenkins, bitbucket
  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_0 on 2017-08-31. Score: 1 | Accepted answer
  
  Hello guys I have found the solution,
  So I create ssh keys from my **Jenkins Server**, and then called the private key from my code, this is how it looks like on my project structure:
  
  ```
  root@staging:~/project# tree
  .
  ├── deployment.yaml
  ├── server
  │   └── host
  └── the_private_key
  
  1 directory, 3 files
  
  ```
  
  and my deployment.yaml:
  
  ```
  ---
  - hosts: staging
    become_user: sudo
    tasks:
    - name: populate my project
      git: repo=git@bitbucket.org:source/source.git
           version=master
           dest=/var/www/test/
           key_file=the_private_key
           accept_hostkey=yes
  
  ```
  
  And then I copied **Jenkins Server** public key to **Target Server**, then everything worked well
  
  
  ---
  
  ### Answer by username_1 on 2017-08-29. Score: 1
  
  First make sure that you added the public key to the right repo with the right permission, usually I add it to 'Access keys' so the user has read only permission, then to make sure that is working add the private key to you system so you can use it with using git:
  
  ```
  ssh-add private-key
  git clone <your git repo>
  
  ```
  
  If it's working, add those credential to you jenkins and use them later
  
  > **Comments:**
  > **username_0**: as you can see above I have add the public key to 'Access Key' and the deployment key has read access to the repo, but still I got the same error  
  
  ---
  
  