Capistrano 3部署要求SSH密码,但无法输入 [英] Capistrano 3 deploy asking for SSH passphrase but cannot type it in
问题描述
我正在尝试使用Capistrano 3部署Rails 4应用程序.
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, 'git@bitbucket.org: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
运行cap production deploy
时,我收到以下消息:
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:
我输入密码,然后按Enter键,它就停留在这里,没有任何新的进展.我必须按Ctrl + C才能真正离开终端.
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.
我可以在deploy.rb文件中设置我的 SSH密码吗?
Can I set my SSH password in the deploy.rb file?
推荐答案
我遇到了同样的问题.
我所做的是更改配置.为了避免capistrano要求输入密码,您必须设置`
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
问题是,默认情况下,capistrano会将 forward_agent 设置为 true ,这将使用计算机中生成的密钥在远程代码存储库中进行身份验证.
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.
这篇关于Capistrano 3部署要求SSH密码,但无法输入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!