2013-03-22 87 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線,即使我有我刪除了這條線相同的問題及其對我現在工作的罰款