Rails:卡皮斯特拉诺。权限被拒绝(public 键)
Rails : Capistrano. Permisssion Denied(public key)
我一直在寻找一种使用 capistrano 部署我的应用程序的方法。我目前在 github 和本地服务器上托管一个小型私人存储库,以尝试部署我的测试。我在下面遇到了一个问题和一条错误消息。
我做了以下事情
在服务器上生成一个 ssh 密钥并成功添加它以在 repo 中部署密钥并进行测试(git@github.com)
在客户端生成一个ssh密钥并成功添加到repo中部署密钥
设置私有存储库。并让帐户部署者有权部署
- 配置 deploy.rb 和生产 rb 以模仿那里的许多其他模板。
我还是不明白为什么会出现这样的错误
DEBUG [a5554d3d] Command: /usr/bin/env chmod +x /tmp/App/git-ssh.sh
INFO [a5554d3d] Finished in 0.020 seconds with exit status 0 (successful).
INFO [b1517df1] Running /usr/bin/env git ls-remote --heads git@github.com:aceofw
ings/App.git as deploy@192.168.1.84
DEBUG [b1517df1] Command: ( GIT_ASKPASS=/bin/echo GIT_SSH=/tmp/App/git-ssh
.sh /usr/bin/env git ls-remote --heads git@github.com:aceofwings/App.git )
DEBUG [b1517df1] Permission denied (publickey).
DEBUG [b1517df1] fatal: Could not read from remote repository.
DEBUG [b1517df1]
DEBUG [b1517df1] Please make sure you have the correct access rights
DEBUG [b1517df1] and the repository exists.
(Backtrace restricted to imported tasks)
cap aborted!
SSHKit::Runner::ExecuteError: Exception while executing as deploy@192.168.1.84:
git exit status: 128
git stdout: Nothing written
git stderr: Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
SSHKit::Command::Failed: git exit status: 128
git stdout: Nothing written
Deploy.rb 文件
###############Deploy.rb##################
# config valid only for current version of Capistrano
lock '3.4.0'
set :repo_url, 'git@github.com:aceofwings/App.git'
set :application, 'App'
set :user, 'deploy'
#set :pty, true
# Default branch is :master
# ask :branch, `git rev-parse --abbrev-ref HEAD`.chomp
# Default value for linked_dirs is []
# set :linked_dirs, fetch(:linked_dirs, []).push('log', 'tmp/pids', 'tmp/cache', 'tmp/sockets', 'vendor/bundle', 'public/system')
namespace :deploy do
after :restart, :clear_cache do
on roles(:web), in: :groups, limit: 3, wait: 10 do
# Here we can do anything such as:
# within release_path do
# execute :rake, 'cache:clear'
# end
end
end
end
Production.rb
server '192.168.1.84', user: 'deploy', roles: %w{app db web}
#set :stage, :production
role :app, %w{deploy@192.168.1.84}
role :web, %w{deploy@192.168.1.84}
role :db, %w{deploy@192.168.1.84}
set :ssh_options, {
forward_agent: false,
auth_methods: %w(password),
password: 'Deploy4Real',
user: 'deploy'
}
我认为您的 capistrano 可能在其 git 缓存中有一些旧文件,可能是由于重命名存储库或类似的东西。尝试 delete 服务器上 shared
文件夹中的 cached-copy
文件夹,这样 capistrano 会再次提取您的 repo。
你应该在production.rb中设置:
forward_agent: true
我在使用 Capistrano 3.4 时遇到了同样的问题。对于 Capistrano 3.2.1,它似乎忽略了这个参数。
您可以使用 capistrano-ssh-doctor 来解决可能的配置问题。
我遇到了类似的问题。事实证明,SSH 代理不是 运行。我在查看 Capistrano 文档时发现了这一点:http://capistranorb.com/documentation/getting-started/authentication-and-authorisation/
运行 这个命令:
$ ssh-add -l
显示我的 public 密钥没有添加到代理中,所以我必须添加它:
$ ssh-add
添加身份:/Users/me/.ssh/id_rsa (/Users/me/.ssh/id_rsa)
在此之后,我的 Capistrano 部署成功了。
我一直在寻找一种使用 capistrano 部署我的应用程序的方法。我目前在 github 和本地服务器上托管一个小型私人存储库,以尝试部署我的测试。我在下面遇到了一个问题和一条错误消息。
我做了以下事情
在服务器上生成一个 ssh 密钥并成功添加它以在 repo 中部署密钥并进行测试(git@github.com)
在客户端生成一个ssh密钥并成功添加到repo中部署密钥
设置私有存储库。并让帐户部署者有权部署
- 配置 deploy.rb 和生产 rb 以模仿那里的许多其他模板。
我还是不明白为什么会出现这样的错误
DEBUG [a5554d3d] Command: /usr/bin/env chmod +x /tmp/App/git-ssh.sh
INFO [a5554d3d] Finished in 0.020 seconds with exit status 0 (successful).
INFO [b1517df1] Running /usr/bin/env git ls-remote --heads git@github.com:aceofw
ings/App.git as deploy@192.168.1.84
DEBUG [b1517df1] Command: ( GIT_ASKPASS=/bin/echo GIT_SSH=/tmp/App/git-ssh
.sh /usr/bin/env git ls-remote --heads git@github.com:aceofwings/App.git )
DEBUG [b1517df1] Permission denied (publickey).
DEBUG [b1517df1] fatal: Could not read from remote repository.
DEBUG [b1517df1]
DEBUG [b1517df1] Please make sure you have the correct access rights
DEBUG [b1517df1] and the repository exists.
(Backtrace restricted to imported tasks)
cap aborted!
SSHKit::Runner::ExecuteError: Exception while executing as deploy@192.168.1.84:
git exit status: 128
git stdout: Nothing written
git stderr: Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
SSHKit::Command::Failed: git exit status: 128
git stdout: Nothing written
Deploy.rb 文件
###############Deploy.rb##################
# config valid only for current version of Capistrano
lock '3.4.0'
set :repo_url, 'git@github.com:aceofwings/App.git'
set :application, 'App'
set :user, 'deploy'
#set :pty, true
# Default branch is :master
# ask :branch, `git rev-parse --abbrev-ref HEAD`.chomp
# Default value for linked_dirs is []
# set :linked_dirs, fetch(:linked_dirs, []).push('log', 'tmp/pids', 'tmp/cache', 'tmp/sockets', 'vendor/bundle', 'public/system')
namespace :deploy do
after :restart, :clear_cache do
on roles(:web), in: :groups, limit: 3, wait: 10 do
# Here we can do anything such as:
# within release_path do
# execute :rake, 'cache:clear'
# end
end
end
end
Production.rb
server '192.168.1.84', user: 'deploy', roles: %w{app db web}
#set :stage, :production
role :app, %w{deploy@192.168.1.84}
role :web, %w{deploy@192.168.1.84}
role :db, %w{deploy@192.168.1.84}
set :ssh_options, {
forward_agent: false,
auth_methods: %w(password),
password: 'Deploy4Real',
user: 'deploy'
}
我认为您的 capistrano 可能在其 git 缓存中有一些旧文件,可能是由于重命名存储库或类似的东西。尝试 delete 服务器上 shared
文件夹中的 cached-copy
文件夹,这样 capistrano 会再次提取您的 repo。
你应该在production.rb中设置:
forward_agent: true
我在使用 Capistrano 3.4 时遇到了同样的问题。对于 Capistrano 3.2.1,它似乎忽略了这个参数。
您可以使用 capistrano-ssh-doctor 来解决可能的配置问题。
我遇到了类似的问题。事实证明,SSH 代理不是 运行。我在查看 Capistrano 文档时发现了这一点:http://capistranorb.com/documentation/getting-started/authentication-and-authorisation/
运行 这个命令:
$ ssh-add -l
显示我的 public 密钥没有添加到代理中,所以我必须添加它:
$ ssh-add
添加身份:/Users/me/.ssh/id_rsa (/Users/me/.ssh/id_rsa)
在此之后,我的 Capistrano 部署成功了。