Jenkins Failed to Connect to Repository
<p>I am trying to connect Jenkins to a private BitBucket repository.</p>

<p>I have a set (both id_rsa and id_rsa.pub) of SSH keys generated at <code>/var/lib/jenkins/.ssh</code>. I've copied the <code>id_rsa.pub</code> key and pasted it in the deploy keys section of my BitBucket repository. Similarly, running the command <code>git ls-remote -h git@bitbucket.org:user/project.git</code> has a valid return and has been added to <code>known_hosts</code>. </p>

<p>What might be causing my Jenkins to not connect in the git Source Code Management section of Jenkins? The error returned is:</p>

<blockquote>
  <p>Failed to connect to repository : Command "git -c core.askpass=true ls-remote -h <a href="https://git@bitbucket.org/user/project.git" rel="nofollow noreferrer">https://git@bitbucket.org/user/project.git</a> HEAD" returned status code 128:
  stdout: 
  stderr: remote: Invalid username or password. If you log in via a third party service you must ensure you have an account password set in your account profile.
  fatal: Authentication failed for '<a href="https://git@bitbucket.org/user/project.git/" rel="nofollow noreferrer">https://git@bitbucket.org/user/project.git/</a>'</p>
</blockquote>

<p>I also tried <code>ssh -Tv git@bitbucket.org</code> as per <a href="https://confluence.atlassian.com/bitbucket/troubleshoot-ssh-issues-271943403.html" rel="nofollow noreferrer"><strong>this doc</strong></a> from Atlassian regarding troubleshooting SSH issues. The return states at that:</p>

<blockquote>
  <p>This deploy key has read access to the following repositories:</p>
  
  <p>user/project: Jenkins -- jenkins@ip-xxx-xx-xx-xxx</p>
</blockquote>