gpt4 book ai didi

ruby-on-rails - SSHKit::Runner::ExecuteError 权限被拒绝

转载 作者:数据小太阳 更新时间:2023-10-29 09:02:04 26 4
gpt4 key购买 nike

尝试通过 gem Capistrano 将我的应用程序部署到主机时遇到问题。通过 SSH key 授权一切正常。我有下一个错误:

(Backtrace restricted to imported tasks)
cap aborted!
SSHKit::Runner::ExecuteError: Exception while executing as hosting_yurta24@calcium.locum.ru: scp: /tmp/yurta24/git-ssh.sh: Permission denied
scp: /tmp/yurta24/git-ssh.sh: Permission denied

我的 deploy.rb 文件是:

lock '3.4.0'

require 'net/ssh/proxy/http'

sshproxy = Net::SSH::Proxy::HTTP.new('x.x.x.x', 8080)
set :ssh_options, { :proxy => sshproxy }

application = 'yurta24'
login = 'yurta24'
$user = 'hosting_' + login
$server = 'calcium.locum.ru'
rvm_ruby_string = '2.1.5p273'
deploy_to = "/home/#{ $user }/projects/#{ application }"
unicorn_conf = "/etc/unicorn/#{ application }.#{ login }.rb"
unicorn_pid = "/var/run/unicorn/#{ $user }/#{ application }.#{ login }.pid"
unicorn_start_cmd = "(cd #{ deploy_to }/current; rvm use #{ rvm_ruby_string } do bundle exec unicorn_rails -Dc #{ unicorn_conf })"

set :application, application
set :repo_url, "https://github.com/verrom/yurta24.git"
set :deploy_to, deploy_to
set :pty, true
set :default_env, { path: "/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games:/usr/local/rvm/bin" }

namespace :deploy do
desc 'Restart application'
task :restart do
on roles(:app), in: :sequence, wait: 5 do
end
end

after :publishing, :restart

after :restart, :clear_cache do
on roles(:web), in: :groups, limit: 3, wait: 10 do
end
end
end

我的 production.rb 文件是:

connect_to = "#{$user}@#{$server}"
role :app, [connect_to]
role :web, [connect_to]
role :db, [connect_to]
set :enable_ssl, true

完整的错误列表是:

verevkinra@ubuntu:~/apps/yurta24$ cap production deploy:check
DEBUG [b5b4061f] Running /usr/bin/env [ -d ~/.rvm ] as hosting_yurta24@calcium.locum.ru
DEBUG [b5b4061f] Command: [ -d ~/.rvm ]
DEBUG [b5b4061f] Finished in 1.346 seconds with exit status 1 (failed).
DEBUG [8c816727] Running /usr/bin/env [ -d /usr/local/rvm ] as hosting_yurta24@calcium.locum.ru
DEBUG [8c816727] Command: [ -d /usr/local/rvm ]
DEBUG [8c816727] Finished in 0.180 seconds with exit status 0 (successful).
DEBUG [a427409d] Running /usr/local/rvm/bin/rvm version as hosting_yurta24@calcium.locum.ru
DEBUG [a427409d] Command: ( PATH=/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games:/usr/local/rvm/bin /usr/local/rvm/bin/rvm version )
DEBUG [a427409d] rvm 1.26.11 (latest) by Wayne E. Seguin <wayneeseguin@gmail.com>, Michal Papis <mpapis@gmail.com> [https://rvm.io/]
DEBUG [a427409d] Finished in 0.468 seconds with exit status 0 (successful).
rvm 1.26.11 (latest) by Wayne E. Seguin <wayneeseguin@gmail.com>, Michal Papis <mpapis@gmail.com> [https://rvm.io/]
DEBUG [205f64d3] Running /usr/local/rvm/bin/rvm current as hosting_yurta24@calcium.locum.ru
DEBUG [205f64d3] Command: ( PATH=/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games:/usr/local/rvm/bin /usr/local/rvm/bin/rvm current )
DEBUG [205f64d3] system
DEBUG [205f64d3] Finished in 0.399 seconds with exit status 0 (successful).
system
DEBUG [730c9a49] Running /usr/local/rvm/bin/rvm default do ruby --version as hosting_yurta24@calcium.locum.ru
DEBUG [730c9a49] Command: ( PATH=/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games:/usr/local/rvm/bin /usr/local/rvm/bin/rvm default do ruby --version )
DEBUG [730c9a49] ruby 2.1.5p273 (2014-11-13) [x86_64-linux-gnu]
DEBUG [730c9a49] Finished in 0.613 seconds with exit status 0 (successful).
ruby 2.1.5p273 (2014-11-13) [x86_64-linux-gnu]
INFO [4c8c1c1b] Running /usr/bin/env mkdir -p /tmp/yurta24/ as hosting_yurta24@calcium.locum.ru
DEBUG [4c8c1c1b] Command: ( PATH=/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games:/usr/local/rvm/bin /usr/bin/env mkdir -p /tmp/yurta24/ )
INFO [4c8c1c1b] Finished in 0.173 seconds with exit status 0 (successful).
DEBUG Uploading /tmp/yurta24/git-ssh.sh 0.0%
(Backtrace restricted to imported tasks)
cap aborted!
SSHKit::Runner::ExecuteError: Exception while executing as hosting_yurta24@calcium.locum.ru: scp: /tmp/yurta24/git-ssh.sh: Permission denied

scp: /tmp/yurta24/git-ssh.sh: Permission denied

我的 Gemfile 是:

 gem 'capistrano-rails'
gem 'capistrano-bundler'
gem 'capistrano-rvm'
gem 'capistrano-rbenv'
gem 'unicorn'

第二个错误列表是:

rake aborted!
Cannot load `Rails.application.database_configuration`:
Could not load database configuration. No such file - ["config/database.yml"]
/home/hosting_yurta24/projects/yurta24/shared/bundle/ruby/2.1.0/gems/railties-4.2.4/lib/rails/application/configuration.rb:110:in `database_configuration'
/home/hosting_yurta24/projects/yurta24/shared/bundle/ruby/2.1.0/gems/activerecord-4.2.4/lib/active_record/railtie.rb:117:in `block (2 levels) in <class:Railtie>'
/home/hosting_yurta24/projects/yurta24/shared/bundle/ruby/2.1.0/gems/activesupport-4.2.4/lib/active_support/lazy_load_hooks.rb:38:in `instance_eval'
/home/hosting_yurta24/projects/yurta24/shared/bundle/ruby/2.1.0/gems/activesupport-4.2.4/lib/active_support/lazy_load_hooks.rb:38:in `execute_hook'
/home/hosting_yurta24/projects/yurta24/shared/bundle/ruby/2.1.0/gems/activesupport-4.2.4/lib/active_support/lazy_load_hooks.rb:45:in `block in run_load_hooks'
/home/hosting_yurta24/projects/yurta24/shared/bundle/ruby/2.1.0/gems/activesupport-4.2.4/lib/active_support/lazy_load_hooks.rb:44:in `each'
/home/hosting_yurta24/projects/yurta24/shared/bundle/ruby/2.1.0/gems/activesupport-4.2.4/lib/active_support/lazy_load_hooks.rb:44:in `run_load_hooks'
/home/hosting_yurta24/projects/yurta24/shared/bundle/ruby/2.1.0/gems/activerecord-4.2.4/lib/active_record/base.rb:315:in `<module:ActiveRecord>'
/home/hosting_yurta24/projects/yurta24/shared/bundle/ruby/2.1.0/gems/activerecord-4.2.4/lib/active_record/base.rb:26:in `<top (required)>'
/home/hosting_yurta24/projects/yurta24/releases/20151020084626/config/initializers/dragonfly.rb:24:in `<top (required)>'
/home/hosting_yurta24/projects/yurta24/shared/bundle/ruby/2.1.0/gems/activesupport-4.2.4/lib/active_support/dependencies.rb:268:in `load'
/home/hosting_yurta24/projects/yurta24/shared/bundle/ruby/2.1.0/gems/activesupport-4.2.4/lib/active_support/dependencies.rb:268:in `block in load'
/home/hosting_yurta24/projects/yurta24/shared/bundle/ruby/2.1.0/gems/activesupport-4.2.4/lib/active_support/dependencies.rb:240:in `load_dependency'
/home/hosting_yurta24/projects/yurta24/shared/bundle/ruby/2.1.0/gems/activesupport-4.2.4/lib/active_support/dependencies.rb:268:in `load'
/home/hosting_yurta24/projects/yurta24/shared/bundle/ruby/2.1.0/gems/railties-4.2.4/lib/rails/engine.rb:652:in `block in load_config_initializer'
/home/hosting_yurta24/projects/yurta24/shared/bundle/ruby/2.1.0/gems/activesupport-4.2.4/lib/active_support/notifications.rb:166:in `instrument'
/home/hosting_yurta24/projects/yurta24/shared/bundle/ruby/2.1.0/gems/railties-4.2.4/lib/rails/engine.rb:651:in `load_config_initializer'
/home/hosting_yurta24/projects/yurta24/shared/bundle/ruby/2.1.0/gems/railties-4.2.4/lib/rails/engine.rb:616:in `block (2 levels) in <class:Engine>'
/home/hosting_yurta24/projects/yurta24/shared/bundle/ruby/2.1.0/gems/railties-4.2.4/lib/rails/engine.rb:615:in `each'
/home/hosting_yurta24/projects/yurta24/shared/bundle/ruby/2.1.0/gems/railties-4.2.4/lib/rails/engine.rb:615:in `block in <class:Engine>'
/home/hosting_yurta24/projects/yurta24/shared/bundle/ruby/2.1.0/gems/railties-4.2.4/lib/rails/initializable.rb:30:in `instance_exec'
/home/hosting_yurta24/projects/yurta24/shared/bundle/ruby/2.1.0/gems/railties-4.2.4/lib/rails/initializable.rb:30:in `run'
/home/hosting_yurta24/projects/yurta24/shared/bundle/ruby/2.1.0/gems/railties-4.2.4/lib/rails/initializable.rb:55:in `block in run_initializers'
/home/hosting_yurta24/projects/yurta24/shared/bundle/ruby/2.1.0/gems/railties-4.2.4/lib/rails/initializable.rb:44:in `each'
/home/hosting_yurta24/projects/yurta24/shared/bundle/ruby/2.1.0/gems/railties-4.2.4/lib/rails/initializable.rb:44:in `tsort_each_child'
/home/hosting_yurta24/projects/yurta24/shared/bundle/ruby/2.1.0/gems/railties-4.2.4/lib/rails/initializable.rb:54:in `run_initializers'
/home/hosting_yurta24/projects/yurta24/shared/bundle/ruby/2.1.0/gems/railties-4.2.4/lib/rails/application.rb:352:in `initialize!'
/home/hosting_yurta24/projects/yurta24/releases/20151020084626/config/environment.rb:5:in `<top (required)>'
/home/hosting_yurta24/projects/yurta24/shared/bundle/ruby/2.1.0/gems/railties-4.2.4/lib/rails/application.rb:328:in `require'
/home/hosting_yurta24/projects/yurta24/shared/bundle/ruby/2.1.0/gems/railties-4.2.4/lib/rails/application.rb:328:in `require_environment!'
/home/hosting_yurta24/projects/yurta24/shared/bundle/ruby/2.1.0/gems/railties-4.2.4/lib/rails/application.rb:457:in `block in run_tasks_blocks'
/home/hosting_yurta24/projects/yurta24/shared/bundle/ruby/2.1.0/gems/sprockets-rails-2.3.3/lib/sprockets/rails/task.rb:64:in `block (2 levels) in define'
Could not load database configuration. No such file - ["config/database.yml"]
/home/hosting_yurta24/projects/yurta24/shared/bundle/ruby/2.1.0/gems/railties-4.2.4/lib/rails/application/configuration.rb:110:in `database_configuration'
/home/hosting_yurta24/projects/yurta24/shared/bundle/ruby/2.1.0/gems/activerecord-4.2.4/lib/active_record/railtie.rb:117:in `block (2 levels) in <class:Railtie>'
/home/hosting_yurta24/projects/yurta24/shared/bundle/ruby/2.1.0/gems/activesupport-4.2.4/lib/active_support/lazy_load_hooks.rb:38:in `instance_eval'
/home/hosting_yurta24/projects/yurta24/shared/bundle/ruby/2.1.0/gems/activesupport-4.2.4/lib/active_support/lazy_load_hooks.rb:38:in `execute_hook'
/home/hosting_yurta24/projects/yurta24/shared/bundle/ruby/2.1.0/gems/activesupport-4.2.4/lib/active_support/lazy_load_hooks.rb:45:in `block in run_load_hooks'
/home/hosting_yurta24/projects/yurta24/shared/bundle/ruby/2.1.0/gems/activesupport-4.2.4/lib/active_support/lazy_load_hooks.rb:44:in `each'
/home/hosting_yurta24/projects/yurta24/shared/bundle/ruby/2.1.0/gems/activesupport-4.2.4/lib/active_support/lazy_load_hooks.rb:44:in `run_load_hooks'
/home/hosting_yurta24/projects/yurta24/shared/bundle/ruby/2.1.0/gems/activerecord-4.2.4/lib/active_record/base.rb:315:in `<module:ActiveRecord>'
/home/hosting_yurta24/projects/yurta24/shared/bundle/ruby/2.1.0/gems/activerecord-4.2.4/lib/active_record/base.rb:26:in `<top (required)>'
/home/hosting_yurta24/projects/yurta24/releases/20151020084626/config/initializers/dragonfly.rb:24:in `<top (required)>'
/home/hosting_yurta24/projects/yurta24/shared/bundle/ruby/2.1.0/gems/activesupport-4.2.4/lib/active_support/dependencies.rb:268:in `load'
/home/hosting_yurta24/projects/yurta24/shared/bundle/ruby/2.1.0/gems/activesupport-4.2.4/lib/active_support/dependencies.rb:268:in `block in load'
/home/hosting_yurta24/projects/yurta24/shared/bundle/ruby/2.1.0/gems/activesupport-4.2.4/lib/active_support/dependencies.rb:240:in `load_dependency'
/home/hosting_yurta24/projects/yurta24/shared/bundle/ruby/2.1.0/gems/activesupport-4.2.4/lib/active_support/dependencies.rb:268:in `load'
/home/hosting_yurta24/projects/yurta24/shared/bundle/ruby/2.1.0/gems/railties-4.2.4/lib/rails/engine.rb:652:in `block in load_config_initializer'
/home/hosting_yurta24/projects/yurta24/shared/bundle/ruby/2.1.0/gems/activesupport-4.2.4/lib/active_support/notifications.rb:166:in `instrument'
/home/hosting_yurta24/projects/yurta24/shared/bundle/ruby/2.1.0/gems/railties-4.2.4/lib/rails/engine.rb:651:in `load_config_initializer'
/home/hosting_yurta24/projects/yurta24/shared/bundle/ruby/2.1.0/gems/railties-4.2.4/lib/rails/engine.rb:616:in `block (2 levels) in <class:Engine>'
/home/hosting_yurta24/projects/yurta24/shared/bundle/ruby/2.1.0/gems/railties-4.2.4/lib/rails/engine.rb:615:in `each'
/home/hosting_yurta24/projects/yurta24/shared/bundle/ruby/2.1.0/gems/railties-4.2.4/lib/rails/engine.rb:615:in `block in <class:Engine>'
/home/hosting_yurta24/projects/yurta24/shared/bundle/ruby/2.1.0/gems/railties-4.2.4/lib/rails/initializable.rb:30:in `instance_exec'
/home/hosting_yurta24/projects/yurta24/shared/bundle/ruby/2.1.0/gems/railties-4.2.4/lib/rails/initializable.rb:30:in `run'
/home/hosting_yurta24/projects/yurta24/shared/bundle/ruby/2.1.0/gems/railties-4.2.4/lib/rails/initializable.rb:55:in `block in run_initializers'
/home/hosting_yurta24/projects/yurta24/shared/bundle/ruby/2.1.0/gems/railties-4.2.4/lib/rails/initializable.rb:44:in `each'
/home/hosting_yurta24/projects/yurta24/shared/bundle/ruby/2.1.0/gems/railties-4.2.4/lib/rails/initializable.rb:44:in `tsort_each_child'
/home/hosting_yurta24/projects/yurta24/shared/bundle/ruby/2.1.0/gems/railties-4.2.4/lib/rails/initializable.rb:54:in `run_initializers'
/home/hosting_yurta24/projects/yurta24/shared/bundle/ruby/2.1.0/gems/railties-4.2.4/lib/rails/application.rb:352:in `initialize!'
/home/hosting_yurta24/projects/yurta24/releases/20151020084626/config/environment.rb:5:in `<top (required)>'
/home/hosting_yurta24/projects/yurta24/shared/bundle/ruby/2.1.0/gems/railties-4.2.4/lib/rails/application.rb:328:in `require'
/home/hosting_yurta24/projects/yurta24/shared/bundle/ruby/2.1.0/gems/railties-4.2.4/lib/rails/application.rb:328:in `require_environment!'
/home/hosting_yurta24/projects/yurta24/shared/bundle/ruby/2.1.0/gems/railties-4.2.4/lib/rails/application.rb:457:in `block in run_tasks_blocks'
/home/hosting_yurta24/projects/yurta24/shared/bundle/ruby/2.1.0/gems/sprockets-rails-2.3.3/lib/sprockets/rails/task.rb:64:in `block (2 levels) in define'
Tasks: TOP => environment
(See full trace by running task with --trace)
rake stderr: Nothing written

Tasks: TOP => deploy:assets:precompile
(See full trace by running task with --trace)
The deploy has failed with an error: Exception while executing as hosting_yurta24@calcium.locum.ru: rake exit status: 1

谢谢。

最佳答案

由于这是一个权限问题,它可能是许多事情之一;但是,请确保您的用户“hosting_yurta24”拥有/tmp 目录

$ sudo chown hosting_yurta24 /tmp

这可能是因为您在创建此用户时没有为其分配管理权限。

关于您的第二个问题,capistrano 报告说您的 VPS 上没有 database.yml 文件。我还假设您没有 secrets.yml。以下是创建它们的方法:

首先确保你有这两个目录。如果您还没有它们,请创建它们:

/home/hosting_yurta24/projects/yurta24/shared/config
/home/hosting_yurta24/projects/yurta24/log

第一个目录将保存您的项目和数据库配置。第二个目录对于您的应用程序保存其日志至关重要。他们都必须在那里!

现在! cd 进入 /home/hosting_yurta24/projects/yurta24/shared/config 并创建两个文件

database.yml
secrets.yml

在 database.yml 中粘贴以下内容:

production:
adapter: postgresql # if your using postgresql
encoding: unicode
pool: 5
timeout: 5000
database: yurta24_production # database name
username: postgres # database username
password: password # database password
host: localhost

回到您的本地机器,进入您的 Rails 项目目录并从终端输入:

rake secret

终端应该转储一长串字符串和数字的混合物。这是您的应用程序 secret 。复制它然后在你的 VPS secrets.yml 上:

production:
secret_key_base: apsifq193uq8djf1jqe8er18jee9jd8eqeh8fqe8fqehh8qehfq # paste your secret here

希望这对您有所帮助。

关于ruby-on-rails - SSHKit::Runner::ExecuteError 权限被拒绝,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33228227/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com