我试图将一个简单的Sinatra应用程序部署到新的EC2实例。我可以使用〜/ .ssh / config文件中的以下设置成功SSH到EC2实例:
Host sinatra_apps
Hostname XX.XX.XX.XX
IdentitiesOnly yes
IdentityFile ~/.ssh/MyPemFile.pem
User ubuntu
使用以下Capistrano配置:
set :application, "mysite.com"
set :repository, "git@github.com:MyUserName/MyRepo.git"
set :scm, :git
set :user, "ubuntu"
set :use_sudo, false
default_run_options[:pty] = true
ssh_options[:forward_agent] = true
ssh_options[:keys] = %w(/Users/MyUser/.ssh/MyPemFile.pem)
ssh_options[:auth_methods] = %w(publickey)
role :web, "ec2-XX-XX-XX-XX.compute-1.amazonaws.com"
role :app, "ec2-XX-XX-XX-XX.compute-1.amazonaws.com"
set :deploy_to, "/var/www/MyApp.com/public_html"
set :deploy_via, :remote_cache
# if you want to clean up old releases on each deploy uncomment this:
after "deploy:restart", "deploy:cleanup"
但是,当我尝试使用Capistrano以详细模式部署我的示例应用程序时,我得到以下内容:
D, [2015-08-04T14:43:04.742704 #83474] DEBUG -- net.ssh.transport.session[3feb73670acc]: establishing connection to ec2-XX-XX-XX-XX.compute-1.amazonaws.com:22
D, [2015-08-04T14:43:05.211088 #83474] DEBUG -- net.ssh.transport.session[3feb73670acc]: connection established
I, [2015-08-04T14:43:05.211261 #83474] INFO -- net.ssh.transport.server_version[3feb736702fc]: negotiating protocol version
D, [2015-08-04T14:43:05.253736 #83474] DEBUG -- net.ssh.transport.server_version[3feb736702fc]: remote is `SSH-2.0-OpenSSH_6.6.1p1 Ubuntu-2ubuntu2'
D, [2015-08-04T14:43:05.253893 #83474] DEBUG -- net.ssh.transport.server_version[3feb736702fc]: local is `SSH-2.0-Ruby/Net::SSH_2.6.7 x86_64-darwin14.0'
D, [2015-08-04T14:43:05.310395 #83474] DEBUG -- tcpsocket[3feb736707c0]: read 1632 bytes
D, [2015-08-04T14:43:05.310529 #83474] DEBUG -- tcpsocket[3feb736707c0]: received packet nr 0 type 20 len 1628
I, [2015-08-04T14:43:05.310609 #83474] INFO -- net.ssh.transport.algorithms[3feb7367543c]: got KEXINIT from server
I, [2015-08-04T14:43:05.310739 #83474] INFO -- net.ssh.transport.algorithms[3feb7367543c]: sending KEXINIT
D, [2015-08-04T14:43:05.310876 #83474] DEBUG -- tcpsocket[3feb736707c0]: queueing packet nr 0 type 20 len 1620
D, [2015-08-04T14:43:05.310951 #83474] DEBUG -- tcpsocket[3feb736707c0]: sent 1624 bytes
I, [2015-08-04T14:43:05.310987 #83474] INFO -- net.ssh.transport.algorithms[3feb7367543c]: negotiating algorithms
D, [2015-08-04T14:43:05.311089 #83474] DEBUG -- net.ssh.transport.algorithms[3feb7367543c]: negotiated:
* kex: diffie-hellman-group-exchange-sha1
* host_key: ssh-rsa
* encryption_server: aes128-cbc
* encryption_client: aes128-cbc
* hmac_client: hmac-sha1
* hmac_server: hmac-sha1
* compression_client: none
* compression_server: none
* language_client:
* language_server:
D, [2015-08-04T14:39:29.132509 #83427] DEBUG -- net.ssh.authentication.session[3fe833025660]: beginning authentication of `ubuntu'
D, [2015-08-04T14:39:29.132628 #83427] DEBUG -- tcpsocket[3fe832f108ec]: queueing packet nr 4 type 5 len 28
D, [2015-08-04T14:39:29.132694 #83427] DEBUG -- tcpsocket[3fe832f108ec]: sent 52 bytes
D, [2015-08-04T14:39:29.246521 #83427] DEBUG -- tcpsocket[3fe832f108ec]: read 52 bytes
D, [2015-08-04T14:39:29.246648 #83427] DEBUG -- tcpsocket[3fe832f108ec]: received packet nr 4 type 6 len 28
D, [2015-08-04T14:39:29.246757 #83427] DEBUG -- net.ssh.authentication.session[3fe833025660]: trying "publickey"
D, [2015-08-04T14:39:29.246877 #83427] DEBUG -- net.ssh.authentication.agent[3fe833029f80]: connecting to ssh-agent
D, [2015-08-04T14:39:29.246972 #83427] DEBUG -- net.ssh.authentication.agent[3fe833029f80]: sending agent request 1 len 49
D, [2015-08-04T14:39:29.247081 #83427] DEBUG -- net.ssh.authentication.agent[3fe833029f80]: received agent packet 2 len 5
D, [2015-08-04T14:39:29.247120 #83427] DEBUG -- net.ssh.authentication.agent[3fe833029f80]: sending agent request 11 len 0
D, [2015-08-04T14:39:29.247309 #83427] DEBUG -- net.ssh.authentication.agent[3fe833029f80]: received agent packet 12 len 2654
D, [2015-08-04T14:39:29.247588 #83427] DEBUG -- net.ssh.authentication.methods.publickey[3fe833024580]: trying publickey (e9:fe:...........)
D, [2015-08-04T14:39:29.247701 #83427] DEBUG -- tcpsocket[3fe832f108ec]: queueing packet nr 5 type 50 len 348
D, [2015-08-04T14:39:29.247771 #83427] DEBUG -- tcpsocket[3fe832f108ec]: sent 372 bytes
D, [2015-08-04T14:39:29.294205 #83427] DEBUG -- tcpsocket[3fe832f108ec]: read 52 bytes
D, [2015-08-04T14:39:29.294337 #83427] DEBUG -- tcpsocket[3fe832f108ec]: received packet nr 5 type 51 len 28
D, [2015-08-04T14:39:29.294412 #83427] DEBUG -- net.ssh.authentication.session[3fe833025660]: allowed methods: publickey
D, [2015-08-04T14:39:29.294516 #83427] DEBUG -- net.ssh.authentication.methods.publickey[3fe833024580]: trying publickey (ec:54:...........)
D, [2015-08-04T14:39:29.294608 #83427] DEBUG -- tcpsocket[3fe832f108ec]: queueing packet nr 6 type 50 len 348
D, [2015-08-04T14:39:29.294689 #83427] DEBUG -- tcpsocket[3fe832f108ec]: sent 372 bytes
D, [2015-08-04T14:39:29.335088 #83427] DEBUG -- tcpsocket[3fe832f108ec]: read 52 bytes
D, [2015-08-04T14:39:29.335215 #83427] DEBUG -- tcpsocket[3fe832f108ec]: received packet nr 6 type 51 len 28
D, [2015-08-04T14:39:29.335280 #83427] DEBUG -- net.ssh.authentication.session[3fe833025660]: allowed methods: publickey
D, [2015-08-04T14:39:29.335379 #83427] DEBUG -- net.ssh.authentication.methods.publickey[3fe833024580]: trying publickey (cd:a5:...........)
D, [2015-08-04T14:39:29.335476 #83427] DEBUG -- tcpsocket[3fe832f108ec]: queueing packet nr 7 type 50 len 348
D, [2015-08-04T14:39:29.335539 #83427] DEBUG -- tcpsocket[3fe832f108ec]: sent 372 bytes
D, [2015-08-04T14:39:29.376015 #83427] DEBUG -- tcpsocket[3fe832f108ec]: read 52 bytes
D, [2015-08-04T14:39:29.376160 #83427] DEBUG -- tcpsocket[3fe832f108ec]: received packet nr 7 type 51 len 28
D, [2015-08-04T14:39:29.376234 #83427] DEBUG -- net.ssh.authentication.session[3fe833025660]: allowed methods: publickey
D, [2015-08-04T14:39:29.376352 #83427] DEBUG -- net.ssh.authentication.methods.publickey[3fe833024580]: trying publickey (84:b0:...........)
D, [2015-08-04T14:39:29.376478 #83427] DEBUG -- tcpsocket[3fe832f108ec]: queueing packet nr 8 type 50 len 348
D, [2015-08-04T14:39:29.376552 #83427] DEBUG -- tcpsocket[3fe832f108ec]: sent 372 bytes
D, [2015-08-04T14:39:29.414819 #83427] DEBUG -- tcpsocket[3fe832f108ec]: read 52 bytes
D, [2015-08-04T14:39:29.414956 #83427] DEBUG -- tcpsocket[3fe832f108ec]: received packet nr 8 type 51 len 28
D, [2015-08-04T14:39:29.415035 #83427] DEBUG -- net.ssh.authentication.session[3fe833025660]: allowed methods: publickey
D, [2015-08-04T14:39:29.415141 #83427] DEBUG -- net.ssh.authentication.methods.publickey[3fe833024580]: trying publickey (4b:52:...........)
D, [2015-08-04T14:39:29.415241 #83427] DEBUG -- tcpsocket[3fe832f108ec]: queueing packet nr 9 type 50 len 348
D, [2015-08-04T14:39:29.415311 #83427] DEBUG -- tcpsocket[3fe832f108ec]: sent 372 bytes
D, [2015-08-04T14:39:29.457789 #83427] DEBUG -- tcpsocket[3fe832f108ec]: read 52 bytes
D, [2015-08-04T14:39:29.457923 #83427] DEBUG -- tcpsocket[3fe832f108ec]: received packet nr 9 type 51 len 28
D, [2015-08-04T14:39:29.458013 #83427] DEBUG -- net.ssh.authentication.session[3fe833025660]: allowed methods: publickey
D, [2015-08-04T14:39:29.458148 #83427] DEBUG -- net.ssh.authentication.methods.publickey[3fe833024580]: trying publickey (84:bb:...........)
D, [2015-08-04T14:39:29.458249 #83427] DEBUG -- tcpsocket[3fe832f108ec]: queueing packet nr 10 type 50 len 348
D, [2015-08-04T14:39:29.458317 #83427] DEBUG -- tcpsocket[3fe832f108ec]: sent 372 bytes
D, [2015-08-04T14:39:29.501289 #83427] DEBUG -- tcpsocket[3fe832f108ec]: read 100 bytes
D, [2015-08-04T14:39:29.501434 #83427] DEBUG -- tcpsocket[3fe832f108ec]: received packet nr 10 type 1 len 76
connection failed for: ec2-XX-XX-XX-XX.compute-1.amazonaws.com (Net::SSH::Disconnect: disconnected: Too many authentication failures for ubuntu (2))
我正在运行以下Capistrano版本:
我觉得我错过了一些简单的事情。好像Capistrano忽略了:keys
参数,因为Capistrano发送到服务器的6个SSH密钥都不匹配我在AWS上生成的.pem文件的指纹。建议?