我正在尝试获取服务器上的uploads目录,我使用https://github.com/Mixd/wp-deploy作为部署系统。
所有其他SSH命令都有效,例如部署等,但由于某种原因,此命令失败,这是跟踪。
Ivans-MacBook-Pro:project ivanristic$ sudo bundle exec cap production uploads:pull --trace
** Invoke production (first_time)
** Execute production
** Invoke load:defaults (first_time)
** Execute load:defaults
** Invoke uploads:pull (first_time)
** Execute uploads:pull
INFO [46ceea35] Running /usr/bin/env rsync -avzO ec2-user@project.com:/var/www/html/shared/content/uploads/ content/uploads as root@localhost
cap aborted!
SSHKit::Command::Failed: rsync exit status: 3072
rsync stdout: Nothing written
rsync stderr: Permission denied (publickey).
rsync: connection unexpectedly closed (0 bytes received so far) [receiver]
rsync error: error in rsync protocol data stream (code 12) at /SourceCache/rsync/rsync-45/rsync/io.c(453) [receiver=2.6.9]
/Users/ivanristic/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/sshkit-1.7.1/lib/sshkit/command.rb:95:in `exit_status='
/Users/ivanristic/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/sshkit-1.7.1/lib/sshkit/backends/local.rb:85:in `block (2 levels) in _execute'
/Users/ivanristic/.rbenv/versions/2.2.0/lib/ruby/2.2.0/open3.rb:199:in `popen_run'
/Users/ivanristic/.rbenv/versions/2.2.0/lib/ruby/2.2.0/open3.rb:93:in `popen3'
/Users/ivanristic/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/sshkit-1.7.1/lib/sshkit/backends/local.rb:63:in `block in _execute'
/Users/ivanristic/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/sshkit-1.7.1/lib/sshkit/backends/local.rb:58:in `tap'
/Users/ivanristic/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/sshkit-1.7.1/lib/sshkit/backends/local.rb:58:in `_execute'
/Users/ivanristic/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/sshkit-1.7.1/lib/sshkit/backends/local.rb:27:in `execute'
/Library/WebServer/Documents/project/lib/capistrano/tasks/content.cap:16:in `block (4 levels) in <top (required)>'
/Library/WebServer/Documents/project/lib/capistrano/tasks/content.cap:15:in `each'
/Library/WebServer/Documents/project/lib/capistrano/tasks/content.cap:15:in `block (3 levels) in <top (required)>'
/Users/ivanristic/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/sshkit-1.7.1/lib/sshkit/backends/local.rb:15:in `instance_exec'
/Users/ivanristic/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/sshkit-1.7.1/lib/sshkit/backends/local.rb:15:in `run'
/Users/ivanristic/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/capistrano-3.4.0/lib/capistrano/dsl.rb:59:in `run_locally'
/Library/WebServer/Documents/project/lib/capistrano/tasks/content.cap:14:in `block (2 levels) in <top (required)>'
/Users/ivanristic/.rbenv/versions/2.2.0/lib/ruby/2.2.0/rake/task.rb:240:in `call'
/Users/ivanristic/.rbenv/versions/2.2.0/lib/ruby/2.2.0/rake/task.rb:240:in `block in execute'
/Users/ivanristic/.rbenv/versions/2.2.0/lib/ruby/2.2.0/rake/task.rb:235:in `each'
/Users/ivanristic/.rbenv/versions/2.2.0/lib/ruby/2.2.0/rake/task.rb:235:in `execute'
/Users/ivanristic/.rbenv/versions/2.2.0/lib/ruby/2.2.0/rake/task.rb:179:in `block in invoke_with_call_chain'
/Users/ivanristic/.rbenv/versions/2.2.0/lib/ruby/2.2.0/monitor.rb:211:in `mon_synchronize'
/Users/ivanristic/.rbenv/versions/2.2.0/lib/ruby/2.2.0/rake/task.rb:172:in `invoke_with_call_chain'
/Users/ivanristic/.rbenv/versions/2.2.0/lib/ruby/2.2.0/rake/task.rb:165:in `invoke'
/Users/ivanristic/.rbenv/versions/2.2.0/lib/ruby/2.2.0/rake/application.rb:150:in `invoke_task'
/Users/ivanristic/.rbenv/versions/2.2.0/lib/ruby/2.2.0/rake/application.rb:106:in `block (2 levels) in top_level'
/Users/ivanristic/.rbenv/versions/2.2.0/lib/ruby/2.2.0/rake/application.rb:106:in `each'
/Users/ivanristic/.rbenv/versions/2.2.0/lib/ruby/2.2.0/rake/application.rb:106:in `block in top_level'
/Users/ivanristic/.rbenv/versions/2.2.0/lib/ruby/2.2.0/rake/application.rb:115:in `run_with_threads'
/Users/ivanristic/.rbenv/versions/2.2.0/lib/ruby/2.2.0/rake/application.rb:100:in `top_level'
/Users/ivanristic/.rbenv/versions/2.2.0/lib/ruby/2.2.0/rake/application.rb:78:in `block in run'
/Users/ivanristic/.rbenv/versions/2.2.0/lib/ruby/2.2.0/rake/application.rb:176:in `standard_exception_handling'
/Users/ivanristic/.rbenv/versions/2.2.0/lib/ruby/2.2.0/rake/application.rb:75:in `run'
/Users/ivanristic/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/capistrano-3.4.0/lib/capistrano/application.rb:15:in `run'
/Users/ivanristic/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/capistrano-3.4.0/bin/cap:3:in `<top (required)>'
/Users/ivanristic/.rbenv/versions/2.2.0/bin/cap:23:in `load'
/Users/ivanristic/.rbenv/versions/2.2.0/bin/cap:23:in `<main>'
Tasks: TOP => uploads:pull
Deploy.rb:
# config valid only for Capistrano 3.4
lock '3.4.0'
############################################
# Setup WordPress
############################################
set :wp_user, "Ivan" # The admin username
set :wp_email, "somemail" # The admin email address
set :wp_sitename, "some title" # The site title
set :wp_localurl, "http://localhost/project/wordpress" # Your local environment URL
############################################
# Setup project
############################################
set :application, "someappname"
set :repo_url, "git@github.com:Ivan0905/project.git"
set :scm, :git
set :git_strategy, SubmoduleStrategy
############################################
# Setup Capistrano
############################################
set :log_level, :info
set :use_sudo, false
set :ssh_options, {
forward_agent: true,
keys: ["/Users/ivanristic/ssh/EC2-key.pem"]
}
set :keep_releases, 5
############################################
# Linked files and directories (symlinks)
############################################
set :linked_files, %w{wp-config.php .htaccess}
set :linked_dirs, %w{content/uploads}
Production.rb
############################################
# Setup Server
############################################
set :stage, :production
set :stage_url, "https://project.com"
server "project.com", user: "ec2-user", roles: %w{web app db}
set :deploy_to, "/var/www/html"
############################################
# Setup Git
############################################
set :branch, "master"
############################################
# Extra Settings
############################################
#specify extra ssh options:
#set :ssh_options, {
# auth_methods: %w(password),
# password: 'password',
# user: 'username',
#set :ssh_options, {
# forward_agent: true,
# auth_methods: ["publickey"],
# keys: ["/Users/ivanristic/ssh/Bill-key.pem"]
#}
#specify a specific temp dir if user is jailed to home
#set :tmp_dir, "/path/to/custom/tmp"
ec2键有效,适用于以下内容:
bundle exec cap production deploy
但由于某种原因,当我尝试从生产中获取上传目录时,它无效。
上传目录确实存在于/ var / www / html / shared / content / uploads,而且填充的很多。
答案 0 :(得分:0)
首先,我假设您知道以root身份运行此类命令是不好的做法,无论如何您都有充分的理由这样做。
ssh键以某种方式搞砸了。这一行:
rsync stderr: Permission denied (publickey).
正在指出这一点。
我不确定为什么它试图在localhost上以root身份运行rsync命令。可能是没有为root用户安装ssh密钥。
尝试运行
rsync -avzO ec2-user@project.com:/var/www/html/shared/content/uploads/ content/uploads
看看是否有光。