Rails 4 + Capistrano 3 : fatal: Could not read from remote repository while deploying

大兔子大兔子 提交于 2019-12-03 00:53:13
Amit Patel

Current Solution

Lately I use different solution. Before cap production deploy I run following commands.

  1. eval "$(ssh-agent -s)"
  2. ssh-add ~/.ssh/id_rsa

Previous Solution

I am able to fix this issue by replacing

set :repo_url, 'git@github.com:BoTreeConsultingTeam/magnificent.git'

with

set :repo_url, 'https://my_github_username:my_github_password@github.com/BoTreeConsultingTeam/magnificent'

Note if your password contains special characters then thet should be url encoded. You can quickly encode using URI::encode in irb.

With other deployments using Capistrano 2, I never need to supply github credentials.

Can anybody please tell why should I have to specify git username/password in repo_url?

There is one more solution in the upcase forum post which also worked.

I had this problem too. Turns out I had loaded the wrong SSH key and it interfered with the deployment. Solved it by removing the wrong loaded ssh key like so:

ssh-add -d ~/.ssh/wrong-ssh-key

and then running the Capistrano deployment again.

I had similar problem(ubuntu). ssh-agent should be on. You can add it to startup applications.

This could also happen if you are deploying to the server for the first time, and the git server is not in the known host list of your deployment server.

so, logging into the remote server and then doing a git request to the repository will cause the git server to be added to the known host list.

like so:

git ls-remote git@bitbucket.org:your_gitbucket_user_id/your_repo.git master

The authenticity of host 'bitbucket.org (104.192.143.2)' can't be established.
RSA key fingerprint is SHA256:zzXQOXSRBEiUtuE8AikJYKwbHaxvSc0ojabwzha.
Are you sure you want to continue connecting (yes/no)? yes

you should confirm to connect.

Warning: Permanently added 'bitbucket.org,104.192.143.2' (RSA) to the list of known hosts.

Now try deploying using the capistrano task.

cap production deploy
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!