I'm trying to use Capistrano 3 to deploy a Rails 4 application.
#config valid only for Capistrano 3.1
lock '3.1.0'
set :application, 'testapp'
set :scm, :git
set :repo_url, '[email protected]:sergiotapia/testapp.git'
set :user, "deploy" # The user on the VPS server.
set :password, "hunter2$$"
set :use_sudo, false
set :deploy_to, "/home/deploy/www/testapp"
set :deploy_via, :remote_cache
set :pty, true
set :format, :pretty
set :keep_releases, 1
set :rails_env, "production"
set :migrate_target, :latest
namespace :deploy do
desc 'Restart application'
task :restart do
on roles(:app), in: :sequence, wait: 5 do
# Your restart mechanism here, for example:
# execute :touch, release_path.join('tmp/restart.txt')
execute :touch, release_path.join('tmp/restart.txt')
system "curl --silent #{fetch(:ping_url)}"
end
end
after :publishing, :restart
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
When running cap production deploy
I get the following message:
DEBUG [322bb1fd] Enter passphrase for key '/home/deploy/.ssh/id_rsa':
When I type in the terminal, I can see the characters, normally you just see whitespace when typing in passwords, right?
DEBUG [484154d4] Enter passphrase for key '/home/deploy/.ssh/id_rsa':
qwef
ewf
qw
ef
qwef
wqe
f
qwef
wqe
f
^Ccap aborted!
Interrupt:
I type in the password and press enter, and it just stays there without any new developments. I have to Ctrl + C to actually leave the terminal.
Can I set my SSH password in the deploy.rb file?
$ ssh-keygen -p -f ~/.ssh/id_ed25519 > Enter old passphrase: [Type old passphrase] > Key has comment '[email protected]' > Enter new passphrase (empty for no passphrase): [Type new passphrase] > Enter same passphrase again: [Repeat the new passphrase] > Your identification has been saved with the new passphrase.
If you lose your SSH key passphrase, there's no way to recover it. You'll need to generate a brand new SSH keypair or switch to HTTPS cloning so you can use your GitHub password instead. If you lose your SSH key passphrase, there's no way to recover it.
SSH keys with passphrase or without itUsing passphrases increases the security when you are using SSH keys. Using a key without a passphrase can be risky. If someone obtains a key (from a backup tape, or a one-time vulnerability) that doesn't include a passphrase, the remote account can be compromised.
I had the same problem.
What I did was to change my configuration. In order to avoid capistrano asking for the passphrase you have to set`
set :pty, false
Then you have to generate your deploy keys in whichever computer you are using to fire the terminal (You can find a very nice guide here https://confluence.atlassian.com/display/BITBUCKET/Set+up+SSH+for+Git specially if you are using bitbucket) and run cap production deploy
The thing is that by default, capistrano will set the forward_agent as true which will use the keys generated in your computer to authenticate in the remote code repo.
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