0

Im trying to create a new user to deploy my application from my local machine to my external server.

I've got it working using root but understand it's not secure to use root, therefore I want to create a user called 'deployer'. I've added this user to my external server and copied my local is_rsa.pub key to /.ssh/authorized_keys on the server, however when I run cap development deploy I keep getting the following error:

failed: "sh -c 'if [ -d /var/www/vhosts/xyz.co.uk/shared/cached-copy ]; then cd
  /var/www/vhosts/xyz.co.uk/shared/cached-copy && git fetch -q origin && git fetch --
tags -q origin && git reset -q --hard 2b738f4ca8008dcf9e84c4be5d63d906a7bfd760 && git clean 
-q -d -x -f; else git clone -q git@github.com:xyz/xyz.co.uk.git 
/var/www/vhosts/xyz.co.uk/shared/cached-copy && cd /var/www/vhosts/xyz.co.uk/shared/cached-
copy && git checkout -q -b deploy 2b738f4ca8008dcf9e84c4be5d63d906a7bfd760; fi'" on 
x.xx.xx.xxx

If I run ssh -T git@github.com on the external server it says:

Hi username! You've successfully authenticated, but GitHub does not provide shell access.

This username is not deployer though, I assume its the username of the github account.

Any ideas what I need to do? Do I need to create the deployer user on my local machine too?

Here is my deploy.rb file:

set :stage_dir, 'app/config/deploy' # needed for Symfony2 only
set :stages, %w(production staging development)
require 'capistrano/ext/multistage'

set :application,           "xyz.co.uk"
set :user,                  "deployer"  # The server's user for deploys

set :normalize_asset_timestamps, false

set :repository,            "git@github.xyz/xyz.co.uk.git"
set :scm,                   :git
set :keep_releases,         3
after "deploy:update",      "deploy:cleanup"
set :use_sudo,              false
set :web_path,              "web"
set :shared_files,          ["app/config/parameters.yml"]
set :shared_children,       [app_path + "/logs", web_path + "/uploads"]
set :use_composer,          true
set :update_vendors,        true
set :dump_assetic_assets,   true
set :deploy_via,            :remote_cache

#logger.level = Logger::MAX_LEVEL

after "deploy:update_code" do
  capifony_pretty_print "--> Ensuring cache directory permissions"
  run "setfacl -R -m u:www-data:rwX -m u:`whoami`:rwX #{latest_release}/#{cache_path}"
  run "setfacl -dR -m u:www-data:rwX -m u:`whoami`:rwX #{latest_release}/#{cache_path}"
  capifony_puts_ok
end

deveopment.rb file:

server 'x.xx.xx.xxx', :app, :web, :db, :primary => true
ssh_options[:port] = 1234
ssh_options[:forward_agent] = true
default_run_options[:pty] = true
set :deploy_to, "/var/www/vhosts/xyz.co.uk"
set :symfony_env_prod, "dev"
set :branch, "develop"

# Need to clear *_dev controllers
set :clear_controllers,     false

Thanks

4

2 回答 2

1

您希望目标机器使用您的本地 SSH 凭据向 Github 进行身份验证。通过将以下两个条目放入您的 deploy.rb 来做到这一点

ssh_options[:forward_agent] = true
default_run_options[:pty] = true

或者,另一种方法是转到您的 Github 存储库并将目标服务器的公共 SSH 密钥添加为部署密钥

https://github.com/your_github/your_repo/settings/keys

这使目标服务器可以仅访问指定的存储库,而无需使用您的个人 SSH 密钥。

于 2013-04-09T05:46:09.180 回答
0

问题是因为“部署者”用户在服务器上没有写权限。

于 2013-04-10T07:56:08.620 回答