2013-03-22 96 views
0

我试图在AWS-EC2实例上与Capistrano部署一个Rails应用程序,在另一个用户的家中使用默认用户(Ubuntu),但它给了我一个“Permission Denied”错误。这是我的代码:部署Rails应用程序在AWS EC2与Capistrano

server "9.9.9.9", :web, :app, :db, primary: true 

set :application, "some_app" 
set :user, "ubuntu" 
set :keep_releases, 3 
set :location, "9.9.9.9" 
ssh_options[:keys] = ["~/Keys/serverkey.pem"] 
ssh_options[:forward_agent] = true 
default_run_options[:pty] = true 
set :use_sudo, false 

task :hello do 
    run "echo 'Hello World' > /home/other_user/i_was_here.txt" 
end 

这是输出:

$ cap hello 
    * 2013-03-22 14:11:29 executing `hello' 
    * executing "echo 'Hello World' > /home/other_user/i_was_here.txt" 
    servers: ["9.9.9.9"] 
    [9.9.9.9] executing command 
** [out :: 9.9.9.9] sh: cannot create /home/other_user/i_was_here.txt: Permission denied 
    command finished in 798ms 
failed: "sh -c 'echo '\\''Hello World'\\'' > /home/other_user/i_was_here.txt'" on 9.9.9.9 

出了什么问题?其目的是部署一个Rails应用程序对于其他用户,让我有些疑惑:

  1. 有没有上的AWS-EC2实例直接与其他用户部署Rails应用程序的方法吗?
  2. 如果#1的答案是“否”,那么为其他用户使用默认用户Ubuntu部署Rails应用的正确方法是什么? (当其他用户尝试访问应用程序时将来未遇到权限问题)

在服务器中,由于我们希望为每个用户获取存储空间和带宽,所以我们在服务器上管理了许多用户这样,直到今天,我们开始与卡皮斯特拉诺哈哈。

在此先感谢。

回答

1

通常是部署为应该运行/维护应用程序的用户。否则,你必须确保两个用户都不会混淆权限。

这种情况的原因是您不想共享凭据?如果是这样,请考虑使用为每个用户添加.ssh/authorized_keys的特殊部署ssh密钥。

0

除非使用sudo,否则ubuntu用户无权访问other_user的主目录,或者更改/ home/other_user上的权限。

如果您想以other_user身份运行应用程序,最佳方法是将capistrano配置为以other_user身份部署。您需要将您的公共ssh密钥添加到/home/other_user/.ssh/authorized_keys。如果您希望应用程序以ubuntu运行,请将其部署到/ home/ubuntu。

1

从您的配置文件ssh_options[:forward_agent] = true线,即使我有我删除了这条线相同的问题及其对我现在工作的罚款

相关问题