我正在尝试创建一个新用户,将我的应用程序从本地计算机部署到外部服务器。
我已经使用root工作但是理解使用root是不安全的,因此我想创建一个名为'deployer'的用户。我已将此用户添加到我的外部服务器并将本地is_rsa.pub密钥复制到服务器上的/.ssh/authorized_keys,但是当我运行cap development deploy
时,我不断收到以下错误:
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
如果我在外部服务器上运行ssh -T git@github.com,它会说:
Hi username! You've successfully authenticated, but GitHub does not provide shell access.
这个用户名不是部署者,我假设它是github帐户的用户名。
我需要做什么?我是否还需要在本地计算机上创建部署用户?
这是我的deploy.rb文件:
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文件:
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
由于
答案 0 :(得分: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密钥。
答案 1 :(得分:0)
问题是因为'部署者'用户没有对服务器的写权限。