I've been looking at a way to deploy my app using capistrano. I currently am hosting a small private repo on github and a local server to try deploying my test. I come upon a problem and an error message below.
I have done the following
Generate an ssh key on server and added it sucessfully to deploy keys in repo and tested([email protected])
Generate an ssh key on client and add it sucessfully to deploy keys in repo
setup a private repository. And have account deployer with rights to deploy
I still cannnot figure why it is giving me an error like this
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 [email protected]:aceofw
ings/App.git as [email protected]
DEBUG [b1517df1] Command: ( GIT_ASKPASS=/bin/echo GIT_SSH=/tmp/App/git-ssh
.sh /usr/bin/env git ls-remote --heads [email protected]: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 [email protected]:
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
The Deploy.rb file
###############Deploy.rb##################
# config valid only for current version of Capistrano
lock '3.4.0'
set :repo_url, '[email protected]: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{[email protected]}
role :web, %w{[email protected]}
role :db, %w{[email protected]}
set :ssh_options, {
forward_agent: false,
auth_methods: %w(password),
password: 'Deploy4Real',
user: 'deploy'
}
I had a similar problem. It turns out that the SSH agent was not running. I found this out looking at the Capistrano documentation: http://capistranorb.com/documentation/getting-started/authentication-and-authorisation/
Running this command:
$ ssh-add -l
showed me that my public key was not added to the agent so I had to add it:
$ ssh-add
Identity added: /Users/me/.ssh/id_rsa (/Users/me/.ssh/id_rsa)
After this my Capistrano deployment worked.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With