改变远程数字海洋的git不工作 - Changing remote of git does not work on digital ocean

- 此内容更新于:2016-02-03
主题:

我部署rails应用数字海洋,下面这个链接。当我跟着确切的步骤,它工作得很好。但后来我意识到github库是公共的。我应该是私有的。我创建了一个私人存储库和改变了远程来源在我的本地。我把新的私人的ssh密钥存储库。删除旧的应用程序文件夹在服务器。然后试图远程存储库的克隆,但要求密码。(它应该采取ssh密钥??)。我也改变了部署。rb和nginx。设计,以反映变化的远程存储库,然后给了这个命令,,但是它失败了,由于在git中身份验证失败。它为什么会失败?为什么ssh密钥不生效?

原文:

I'm deploying a rails app on digital ocean, following this link. When I followed the exact steps, it worked perfectly. But then I realized the github repository is public. I should have it as private. I create a private repository and changed the remote origin in my local. I put the ssh keys in the new private repository. Removed the old apps folder in the server. And then tried to clone from the remote repository but it asks for password. (It should have taken the ssh key??).

Also I changed the deploy.rb and nginx.conf to reflect the changes of the remote repository and then gave this command, cap production deploy:initial, but it fails, due to authentication failure in git.

Why does it fail? Why is the ssh key not taking effect?

网友:我没有使用digitalocean但这可能发生,如果你使用地址代替

(原文:I have not used digitalocean but this can occur if you use the https://github.com/... adress instead of git://)

网友:你有任何进展吗?找到了一个解决方案或还有问题吗?

(原文:You got any progress with this? Found a solution or still having the problem?)

解决方案:
这看起来像仍然使用旧的git远程地址。当你改变远程url,这是不够的在等,但是你必须手动更改文件在服务器上的部署dircapistrono已经部署的时候与一个老远程url。所以,如果你有以下内部部署。rb(或)你必须手动编辑服务器上的文件和远程修改条目匹配。
原文:

This looks like capistrano is still using the old git remote address. When you change the remote url, it is not enough to do this inside deploy.rb etc, but you have to manually change the file repo/config inside the deployment dir of capistrono on the server when you already deployed it with an old remote url before.

So, if you have the following inside your deploy.rb (or deploy/production.rb)

set :deploy_to, '/var/www/path/to/deploy'

You have to manually edit the file on the server

/var/www/path/to/deploy/repo/config

and amend the url = XXX entry of your remote to match the new one.

楼主:部署设置这种方式——集

(原文:The set deploy to is set this way - set :deploy_to, "/home/#{fetch(:user)}/apps/#{fetch(:application)}")

网友:和然后,一定是之前声明。

(原文:user and application must have been declared before with set then, too.)

楼主:是的,我真的改变了存储库名称也因此应用程序名称,但忘了改变它在设置应用程序。但即便如此,它要求密码而克隆。或者使用capistrano

(原文:Yup, I actually changed the repository name also and hence the application name but forgot to change it in the set application. but even then it asks for password while cloning. or using capistrano)

网友:在本地机器上它并不问当克隆但当你运行吗?

(原文:On your local machine it does not ask when cloning but when you run cap production deploy:initial?)

楼主:在本地git克隆工作。在服务器git克隆要求密码尽管ssh密钥设置。在当地当我运行帽生产部署:最初的失败,因为身份验证失败。

(原文:On local git clone works. On server git clone asks for password even though ssh key is set. On local when I run cap production deploy:initial it fails because of authentication failure.)

解决方案:
也许是因为你没有启用ssh货运数字海洋吗?要验证,首先编辑本地电脑上:现在尝试运行。如果现在工作没有密码,那么你应该改变匹配您的ssh主机的主机名,所以只有对数字海洋:为你的用例:ForwardAgent使服务器可以使用当地的ssh密钥,所以您的部署用户具有相同的“ssh权利”喜欢你的本地用户。
原文:

Maybe it is because you have not enabled ssh forwarding for digital ocean? To verify, first edit the $HOME/.ssh/config on your local pc:

host *
  ForwardAgent yes

Now try to run cap production deploy:initial. If it works without a password now, then you should change the host * to actually match the hostname of your ssh host, so ForwardAgent is only set for digital ocean:

host digitalocean.com
  ForwardAgent yes

For your use case: ForwardAgent enables the server to use your local ssh keys, so your deploy user has the same "ssh rights" like your local user.