MrB*_*MrB 19 git ssh capistrano
我需要Capistrano使用2个不同的SSH密钥.一个用于git存储库,一个用于服务器部署到.
无论我在.ssh文件夹中重命名为id_rsa的哪个键都有效.另一个没有.如果我将git键重命名为id_rsa,Capistrano可以连接到git存储库,但是无法在服务器上进行身份验证以进行部署.如果我称之为其他东西,它将无法连接到git repo.我知道其他密钥有效,因为我可以执行ssh -i~/.ssh/otherKey.pem并且它将成功连接到服务器.
这就是我在deploy.rb Capistrano文件中的内容.
ssh_options[:keys] = [
File.join(ENV["HOME"], ".ssh", "id_rsa"),
File.join(ENV["HOME"], ".ssh", "deploy")
]
ssh_options[:forward_agent] = true
Run Code Online (Sandbox Code Playgroud)
我如何告诉Capistrano使用钥匙?它似乎只使用名为id_rsa的那个.
编辑:
这是Capistrano的输出,错误信息如下:
$ cap yii deploy
* executing `yii'
Yii
* executing `deploy'
* executing `deploy:update'
** transaction: start
* executing `deploy:update_code'
executing locally: "git ls-remote git@project.beanstalkapp.com:/projectyii.git HEAD"
* executing "git clone -q git@project.beanstalkapp.com:/projectyii.git /var/www/projectyii-trunk/releases/20110824174629 && cd /var/www/projectyii-trunk/releases/20110824174629 && git checkout -q -b deploy 5e14521285ca04a605353e97bdf31c3a2889dbfb && (echo 5e14521285ca04a605353e97bdf31c3a2889dbfb > /var/www/projectyii-trunk/releases/20110824174629/REVISION)"
servers: ["yii.project.com"]
[yii.project.com] executing command
** [yii.project.com :: err] Error reading response length from authentication socket.
** [yii.project.com :: err] Permission denied (publickey,keyboard-interactive).
** [yii.project.com :: err] fatal: The remote end hung up unexpectedly
command finished
*** [deploy:update_code] rolling back
* executing "rm -rf /var/www/projectyii-trunk/releases/20110824174629; true"
servers: ["yii.project.com"]
[yii.project.com] executing command
command finished
failed: "sh -c \"git clone -q git@project.beanstalkapp.com:/projectyii.git /var/www/projectyii-trunk/releases/20110824174629 && cd /var/www/projectyii-trunk/releases/20110824174629 && git checkout -q -b deploy 5e14521285ca04a605353e97bdf31c3a2889dbfb && (echo 5e14521285ca04a605353e97bdf31c3a2889dbfb > /var/www/projectyii-trunk/releases/20110824174629/REVISION)\"" on yii.project.com
Run Code Online (Sandbox Code Playgroud)
编辑:
另一件事:它完全可以从我的本地机器上运行,而不是在部署服务器上 - 具有完全相同的配置文件!似乎Capistrano在我的本地机器上使用了正确的密钥,但在部署机器上却没有.
Paŭ*_*ann 23
免责声明:我对Capistrano一无所知.
如果它只是执行正常ssh
调用(或调用git
此操作),则可以~/.ssh/config
在每个主机(或每个主机别名)的基础上配置正确的密钥.
例如,我在我的~/.ssh/config
文件中有这些行:
# Git bei Github
Host github.com
User git
IdentityFile ~/.ssh/svn_id_rsa
# Andere Mathe-Hosts
Host *.math.hu-berlin.de
User ebermann
IdentityFile ~/.ssh/id_rsa
ControlMaster auto
Run Code Online (Sandbox Code Playgroud)
Vic*_*box 11
我在deploy.rb中有这一行:
ssh_options[:keys] = %w(/Users/victor.pudeyev/ec2/MBP-2.pem)
Run Code Online (Sandbox Code Playgroud)
这表明密钥文件名是空格分隔的,例如
ssh_options[:keys] = %w(/Users/victor.pudeyev/ec2/MBP-1.pem /Users/victor.pudeyev/ec2/MBP-2.pem)
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
22505 次 |
最近记录: |