vagrant自定义ssh密钥认证失败

问题描述 投票:0回答:1

以下是我的流浪者档案

# -*- mode: ruby -*-
# vi: set ft=ruby :

#Virtualbox host and vagrant host/network confs
#
Vagrant.configure("2") do |config|
  config.vm.define "slave" do |slave|
    slave.vm.box = "centos/7"
    slave.vm.hostname = "slave.ansible.com"
    slave.vm.network :private_network, ip: "192.168.99.102"
    slave.ssh.insert_key = false
    slave.vm.boot_timeout = 800
    slave.ssh.private_key_path = ["keys/id_rsa_slave"]
    slave.vm.provision "file", source: "keys/id_rsa_slave.pub", destination: "~/.ssh/authorized_keys"
  end

    config.vm.provider "virtualbox" do |vb|
      vb.cpus = "1"
      vb.memory = "512"
    end

这个Vagrant文件位于我的主目录(usergokulslave)下的slave文件夹中,在这个文件夹下,我有keys目录,有以下keys和适当的权限。

(base) Gokul:slave gokul$ ls -lt keys/
total 16
-rw-------  1 gokul  gokul   565 May 16 18:30 id_rsa_slave.pub
-rw-------  1 gokul  gokul  2590 May 16 18:30 id_rsa_slave

钥匙目录的权限也可以。

(base) Gokul:slave gokul$ ls -ld keys/
drwx------  4 gokul  gokul  128 May 16 18:30 keys/

config

流浪汉

而此时挂断了,无法进行身份验证

==> master: Waiting for machine to boot. This may take a few minutes...
    master: SSH address: 127.0.0.1:2200
    master: SSH username: vagrant
    master: SSH auth method: private key
    master: Warning: Authentication failure. Retrying...
    master: Warning: Authentication failure. Retrying...

SSH authentication failed! This is typically caused by the public/private
keypair for the SSH user not being properly set on the guest VM. Please
verify that the guest VM is setup with the proper public key, and that
the private key path for Vagrant is setup properly as well.

在启用debug后,我也可以看到,它能接收到我要求的私钥,但是,它无法成功认证,并出现上述错误。

ssh vagrant private-key vagrantfile public-key
1个回答
0
投票

所以这个配置

应改为:

slave.ssh.private_key_path = ["keys/id_rsa_slave"]

在做了这个改变之后,我运行了

slave.ssh.private_key_path = ["keys/id_rsa_slave", "~/.vagrant.d/insecure_private_key"]

流浪汉

而且还成功的出现了。

© www.soinside.com 2019 - 2024. All rights reserved.