多服务器部署:询问每台服务器的ssh密码 [英] Multiple server deploy: asking ssh password for each server

查看:79
本文介绍了多服务器部署:询问每台服务器的ssh密码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在设置Capifony(用于Symfony的Capistrano),但是在测试多台服务器部署时出现ssh密码问题。

I'm setting up Capifony (Capistrano for symfony) but I've an issue with ssh password when testing multiple server deploy.

以下版本:

daniel@fiji:~$ ruby --version
ruby 1.8.7 (2011-06-30 patchlevel 352) [i686-linux]

daniel@fiji:~$ cap --version
Capistrano v2.9.0

daniel@fiji:~$ uname -a
Linux fiji 3.0.0-13-generic-pae #22-Ubuntu SMP Wed Nov 2 15:17:35 UTC 2011 i686 i686 i386 GNU/Linux

和来自deploy.rb的一些配置:

And some configurations from deploy.rb:

set :domain, "mydomain"
...
set :user, "sshuser"
set :password, "sshpassword"
...
role :web, domain
role :app, domain
...

部署到单个服务器的效果很好,没有需要输入密码。一切都很好。但是,如果我尝试使用以下配置向配置中添加更多服务器(我需要部署到6到9台计算机):

Deploying to a single server works great, no need to enter passwords. All fine. But if I try to add more servers to the configuration (I'll need to deploy to 6 to 9 machines) with a configuration like this:

...
set :user, "sshuser"
set :password, "sshpassword"
role :web, "ipaddr1", "ipaddr2"
role :app, "ipaddr1", "ipaddr2"
...

Capistrano开始问我列出的每个服务器的ssh密码(即使已设置为以前的密码)...此配置有何问题?输入密码可以使该过程继续进行并可以正常进行,但我想避免每次都输入密码。

Capistrano starts to ask me ssh password for each server listed even if it's set as before...what's wrong with this configuration? Entering the password lets the process continue and all works, but I'd like to avoid to enter the password every time.

感谢
Daniel

Thanks Daniel

推荐答案

我不明白为什么capistrano一直要求您输入密码。但是,解决此问题的一种方法是使用公钥身份验证,这在capistrano Wiki中也建议使用。 (有关示例,请参见本教程

I don't see why capistrano keeps asking for your password. However, one way to solve this issue is to use public key authentication, which is suggested in the capistrano wiki as well. (see this tutorial for an example of how to set this up)

简而言之:


  1. 您生成了一个使用 ssh-keygen -t rsa -C youremail

  2. 您将公共密钥复制到远程主机 scp -p .ssh / id_rsa.pub remoteuser @ remotehost:

  3. 您将公共密钥添加到服务器上的授权密钥文件中: cat id_rsa.pub>> 〜/ .ssh / authorized_keys 。 (您可能需要创建.ssh目录)

  1. You generate a key using ssh-keygen -t rsa -C "youremail"
  2. You copy the public key to the remote host scp -p .ssh/id_rsa.pub remoteuser@remotehost:
  3. You add the public key to the authorized keys file on the server: cat id_rsa.pub >> ~/.ssh/authorized_keys. (You might need to create the .ssh dir)

之后,您只需要输入一次密码即可,需要在您的deploy.rb文件中硬编码您的密码。

After that you should only need to enter your password once and you won't need to have your password hardcoded in your deploy.rb file.

这篇关于多服务器部署:询问每台服务器的ssh密码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆