2016-07-29 17 views
5

Tôi đã gặp phải một vấn đề khó chịu mà tôi không thể đi lại.Vagrant ssh 'Xác thực thất bại. Đang thử lại ... 'lỗi lặp lại - các phím không khớp, không thể tìm thấy sửa lỗi

Tôi cố gắng để vagrant up một hệ thống centos7 trong môi trường này:

  • Windows 10
  • Hyper-V (không kỷ niệm cập nhật phiên bản)
  • Docker hình ảnh "serveit/centos7" hoặc " bluefedora/HyperV-alpha-centos7"
  • OpenSSH cài đặt, cấu hình private key

Nội dung của tôi Vagrantfile:

Vagrant.configure("2") do |config| 
    #config.vm.box = "serveit/centos-7" 
    config.vm.box = "bluefedora/hyperv-alpha-centos7" 
    config.ssh.private_key_path = "~/.vagrant.d/insecure_private_key" 
    config.ssh.forward_agent = true 
end 

Tôi nhận được lỗi này khi làm một vagrant up:

PS C:\Programs\vagrant_stuff\centos7> vagrant up 
Bringing machine 'default' up with 'hyperv' provider... 
==> default: Verifying Hyper-V is enabled... 
==> default: Importing a Hyper-V instance 
    default: Cloning virtual hard drive... 
    default: Creating and registering the VM... 
    default: Successfully imported a VM with name: vagrantbox 
==> default: Starting the machine... 
==> default: Waiting for the machine to report its IP address... 
    default: Timeout: 120 seconds 
    default: IP: 192.168.137.6 
==> default: Waiting for machine to boot. This may take a few minutes... 
    default: SSH address: 192.168.137.6:22 
    default: SSH username: vagrant 
    default: SSH auth method: private key 
    default: 
    default: Vagrant insecure key detected. Vagrant will automatically replace 
    default: this with a newly generated keypair for better security. 
    default: 
    default: Inserting generated public key within guest... 
    default: Removing insecure key from the guest if it's present... 
    default: Key inserted! Disconnecting and reconnecting using new SSH key... 
    default: Warning: Authentication failure. Retrying... 
    default: Warning: Authentication failure. Retrying... 
    default: Warning: Authentication failure. Retrying... 
    default: Warning: Authentication failure. Retrying... 
    default: Warning: Authentication failure. Retrying... 
    default: Warning: Authentication failure. Retrying... 
    default: Warning: Authentication failure. Retrying... 
    default: Warning: Authentication failure. Retrying... 
    default: Warning: Authentication failure. Retrying... 
    default: Warning: Authentication failure. Retrying... 
    default: Warning: Authentication failure. Retrying... 
    default: Warning: Authentication failure. Retrying... 
    default: Warning: Authentication failure. Retrying... 
    default: Warning: Authentication failure. Retrying... 
    default: Warning: Authentication failure. Retrying... 
    default: Warning: Authentication failure. Retrying... 
    default: Warning: Authentication failure. Retrying... 
    default: Warning: Authentication failure. Retrying... 
    default: Warning: Authentication failure. Retrying... 
    default: Warning: Authentication failure. Retrying... 
    default: Warning: Authentication failure. Retrying... 
    default: Warning: Authentication failure. Retrying... 
    default: Warning: Authentication failure. Retrying... 
    default: Warning: Authentication failure. Retrying... 
Timed out while waiting for the machine to boot. This means that 
Vagrant was unable to communicate with the guest machine within 
the configured ("config.vm.boot_timeout" value) time period. 

If you look above, you should be able to see the error(s) that 
Vagrant had when attempting to connect to the machine. These errors 
are usually good hints as to what may be wrong. 

If you're using a custom box, make sure that networking is properly 
working and you're able to connect to the machine. It is a common 
problem that networking isn't setup properly in these boxes. 
Verify that authentication configurations are also setup properly, 
as well. 

If the box appears to be booting properly, you may want to increase 
the timeout ("config.vm.boot_timeout") value. 

tôi có thể làm một vagrant ssh-config:

Host default 
    HostName 192.168.137.6 
    User vagrant 
    Port 22 
    UserKnownHostsFile /dev/null 
    StrictHostKeyChecking no 
    PasswordAuthentication no 
    IdentityFile C:/Users/Kareem/.vagrant.d/insecure_private_key 
    IdentitiesOnly yes 
    LogLevel FATAL 
    ForwardAgent yes 

tôi thấy ở đâu đó rằng tôi nên thử vagrant haltvagrant up để khắc phục sự cố. Điều này không hiệu quả.

Tôi cũng đã xóa tệp .vagrant.d/insecure_private_key và thấy tệp đã được tạo lại. Không có vấn đề, đó cũng là dự kiến.

Cũng vagrant ssh công trình với mật khẩu:

PS C:\Programs\vagrant_stuff\centos7> vagrant ssh 
[email protected]'s password: 
[[email protected] ~]$ 

Vì vậy, bởi vì tôi có thể SSH, tôi quyết định để kiểm tra .ssh/authorized_keys file:

[lang thang @ localhost ~] $ cat .ssh/authorized_keys

[[email protected] ~]$ cat /home/vagrant/.ssh/authorized_keys 
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDIRcYs0HBn/BOjiKg9fGnoraVxRnnZk+6sM3waFFE1+U3aO8GQjRKxQsYgJNoyRmNVymzpP13kOoLodDsz 
UKhdcO6dL+zAtmhsFTgmADMXxVzM3mfRWfPG2HdsU13Pof77A68Ln6z6X4jVG4cnsclYvz67Gudl7lZ9VI2TOdDn1V+7ZANlkGnqejIwA2RVWtYLgLQHU9p4 
47nvRqId71XaG8BZpbONRzzrL49wWyjfc4h6SdaHVJZJB6kY+vkr31xw6TPIIlo2UHH7Ihlk6KADNo4wFJYF+ozIA7C792omzjN1zu1SayvCYNG21yZy/cCd 
n2Hr158Jy83A9CslQPbT vagrant 

Dafuq là khóa này?!?! Tôi khá chắc chắn đây không phải là khóa công khai tương ứng với Vagrant. Đây cũng không phải là khóa công khai của hệ thống của tôi. Khi tôi kiểm tra Vagrant Public key tôi có được điều này:

ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA6NF8iallvQVp22WDkTkyrtvp9eWW6A8YVr+kz4TjGYe7gHzIw+niNltGEFHzD8+v1I2YJ6oXevct1YeS0o9H 
ZyN1Q9qgCgzUFtdOKLv6IedplqoPkcmF0aYet2PkEDo3MlTBckFXPITAMzF8dJSIFo9D8HfdOV0IAdx4O7PtixWKn5y2hMNG0zQPyUecp4pzC6kivAIhyfHi 
lFR61RGL+GPXQ2MWZWFYbAGjyiYJnAmCP3NOTd0jMZEnDkbUvxhMmBYSdETk1rRgm+R4LOzFUGaHqHDLKLX+FIPKcF96hrucXzcWyLbIbEgE98OHlnVYCzRd 
K8jlqm8tehUc9c9WhQ== vagrant insecure public key 

Hơn nữa, nếu tôi cập nhật Vagrantfile tôi để sử dụng hệ thống của tôi private key:

#config.ssh.private_key_path = "~/.vagrant.d/insecure_private_key" 
    config.ssh.private_key_path = "~/.ssh/id_rsa" 

tôi nhận được một khóa công khai khác nhau trong máy ảo, đó là Vagrant Public key:

[[email protected] ~]$ cat /home/vagrant/.ssh/authorized_keys 
ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA6NF8iallvQVp22WDkTkyrtvp9eWW6A8YVr+kz4TjGYe7gHzIw+niNltGEFHzD8+v1I2YJ6oXevct1YeS0o9H 
ZyN1Q9qgCgzUFtdOKLv6IedplqoPkcmF0aYet2PkEDo3MlTBckFXPITAMzF8dJSIFo9D8HfdOV0IAdx4O7PtixWKn5y2hMNG0zQPyUecp4pzC6kivAIhyfHi 
lFR61RGL+GPXQ2MWZWFYbAGjyiYJnAmCP3NOTd0jMZEnDkbUvxhMmBYSdETk1rRgm+R4LOzFUGaHqHDLKLX+FIPKcF96hrucXzcWyLbIbEgE98OHlnVYCzRd 
K8jlqm8tehUc9c9WhQ== vagrant insecure public key 

Tôi cũng thấy rằng quy trình cấp phép không chèn khóa mới. Điều này tất cả dường như ngược, tôi nghĩ rằng chìa khóa chỉ nên được cập nhật nếu tôi sử dụng khóa riêng của tôi, và rằng nó nên sử dụng của riêng tôi.

Giúp đỡ!

Ai đó có thể giúp tôi tìm hiểu lý do tại sao điều này xảy ra không?

Trả lời

7

Hóa ra, có một lỗi được biết đến trong Vagrant 1.8.5 (Sẽ được cố định trong 1.8.6):

Chi tiết here

Nếu bạn đang sử dụng 1.8.5, bạn có thể tải về cập nhật phiên bản từ PR #7611 sử dụng PowerShell:

[IO.File]::WriteAllLines("C:\HashiCorp\Vagrant\embedded\gems\gems\vagrant-1.8.5\plugins\guests\linux\cap\public_key.rb", (Invoke-WebRequest -Uri https://raw.githubusercontent.com/Poohblah/vagrant/41063204ca540c44f9555bd11ba9e76c7307bec5/plugins/guests/linux/cap/public_key.rb).Content)

+2

Từ những ý kiến ​​đó, tôi đã học được tệp để vá trên máy Mac là '/ opt/vagrant/embedded/gems/gems/vagrant-1.8.5/plugins/khách/linux/cap/public_key.rb'. (Các nội dung khác được đưa ra trong liên kết.) Mọi thứ hoạt động tốt sau bản vá đó. – Wildcard

1

SSH vào máy lang thang và cung cấp đặc quyền này.

lang thang @ localhost: chmod 600 ~/.ssh/authorized_keys.

thoát khỏi sự trở lại của máy chủ lưu trữ và nhấn "tải lại âm đạo"

Nó hoạt động !!!

2

Bên public_key.rb tập tin tìm thấy những người ở dòng 56 và thêm chmod 0600 ~/.ssh/authorized_keys như vậy:

  if test -f ~/.ssh/authorized_keys; then 

      grep -v -x -f '#{remote_path}' ~/.ssh/authorized_keys > ~/.ssh/authorized_keys.tmp 

      mv ~/.ssh/authorized_keys.tmp ~/.ssh/authorized_keys 
      chmod 0600 ~/.ssh/authorized_keys 
     fi 

     rm -f '#{remote_path}' 

Đường dẫn dành cho Windows: C:\HashiCorp\Vagrant\embedded\gems\gems\vagrant-1.8.5\plugins\guests\linux\cap\public_key.rb

Đường dẫn cho mac: /opt/vagrant/embedded/gems/gems/vagrant-1.8.5/plugins/guests/linux/cap/public_key.rb

Các vấn đề liên quan