我是Capistrano和Ruby的新手,我似乎无法进行基本部署设置.每次我运行cap deploy:检查我收到以下错误:
服务器:["domain.com"]连接失败:me@domain.com(Net :: SSH :: HostKeyMismatch:fingerprint 0c:de:d4:1b:e9:64:83:3a:8b:d7:c3: 42:98:5b:5d:8c与"[domain.com]:22,[62.39.11.2]:22"不匹配)
我的deploy.db看起来像这样:
set :stages, %w(production staging)
set :default_stage, "staging"
require 'capistrano/ext/multistage'
set :application, "captest" # TODO
set :repository, "git@bitbucket.org:jy312/captest.git" # TODO
set :scm, :git
set :use_sudo, false
ssh_options[:forward_agent] = true
default_run_options[:pty] = true
set :deploy_via, :remote_cache
set :copy_exclude, [".git", ".DS_Store", ".gitignore", ".gitmodules"]
set :git_enable_submodules, 1
Run Code Online (Sandbox Code Playgroud)
我已经尝试将我的本地计算机公钥(id_rsa.pub)添加到我的服务器上的known_hosts列表中,但没有运气.
任何建议将不胜感激.非常感谢您的帮助.
Mus*_*hir 39
目标服务器的指纹与本地known_hosts文件中的指纹不匹配.删除本地known_hosts文件中的现有条目.
您也可以尝试通过直接SSH到服务器而不是通过ruby来解决问题,因为这是一个SSH问题.
或者只是改写它(更改服务器的USERNAME和IP):
$ ssh-keygen -f "/home/USERNAME/.ssh/known_hosts" -R 178.X.X.X
Run Code Online (Sandbox Code Playgroud)
然后进入服务器
$ ssh user@178.X.X.X
Run Code Online (Sandbox Code Playgroud)
并回答 yes
重试部署
祝好运 ;)
虽然不适合生产系统,但如果您在部署到本地开发环境时遇到此问题,您可以考虑告诉 Capistrano 忽略严格的主机密钥验证。
部署.rb
set :ssh_options, paranoid: false
Run Code Online (Sandbox Code Playgroud)
https://github.com/net-ssh/net-ssh/blob/e90551a4672587e294b47f824a401550f55184cc/lib/net/ssh.rb#L160
场景:从源计算机到目标计算机的SSH
如果上面的场景抛出Net :: SSH :: HostKeyMismatch,那么在下面做,
1) Login to source machine and sudo su <User>
2) ssh destination machine
3) in step2, HostKeyMismatch error will be displayed and also the known hosts location.
or
2) cd ~
3) cd .ssh
4) vim known_hosts
5) clear the content of the file and save and quit (using command - :wq)
Run Code Online (Sandbox Code Playgroud)
这应该可以解决问题.