Search code examples
bitbucketcapistranossh-agent

set up ssh with ssh-agent for deployment, Problem following instruction from capistranorb.com


I am trying to follow the documentation about authentication & Authorisation on capistranorb.com, but they use github, I use bitbucket. There is one place where I am stuck because output from the console is different.

The user named deploy on the production server that is described in the article exists. I can ssh into his account. The repo in bitbucket is set up correctly. A colleague of mine can deploy the project without problem, so the problem is my personal setup of my keys. I tried following the instruction on https://capistranorb.com/documentation/getting-started/authentication-and-authorisation/ by the letter. One step doesn't work.

When I do

My-MacBook-Pro-2:myproject myuser$ git config remote.origin.url

the output is

https://MyBitbucketUser@bitbucket.org/myfirm/myproject.git

The article on capistranorb says it should be something like

git@github.com:capistrano/rails3-bootstrap-devise-cancan.git

So there is no https there, and it says git@.

The following command in their documentation is

ssh -A deploy@one-of-my-servers.com 'git ls-remote git@github.com:capistrano/rails3-bootstrap-devise-cancan.git'

Now when I do

ssh -A deploy@myproject.net 'git ls-remote https://MyBitbucketUser@bitbucket.org/myfirm/myproject.git'

I get an error, and also if I omit the https:// bit.

If I include https://, I get the error "fatal: could not read Password for 'https://DcsMarionDickten@bitbucket.org': No such device or address", and if I don't, I get "... does not appear to be a git repository".

I should add that I have set up git to push to bitbucket without its asking me for a password, I have added my public key to the account and this seems to be working.

What is wrong here?

(I should perhaps add that I am chasing a problem connected with the fact that my colleague uses ssh-agent to forward the ssh key authorisation, and my key is set up without a passphrase, since I didn't know you needed to have one.)


Solution

  • ssh-agent has no way to understand HTTPS-based URLs. You need to specify an SSH URL like MyBitbucketUser@bitbucket.org:myfirm/myproject.git instead. (git@bitbucket.org:myfirm/myproject.git will also work, as will ssh://MyBitbucketUser@bitbucket.org/myfirm/myproject.git.)