hashicorp / vagrant

Vagrant is a tool for building and distributing development environments.
https://www.vagrantup.com
Other
26.25k stars 4.43k forks source link

Vagrant 2.3.6 not working with default insecure ssh key #13196

Closed ssasso closed 1 year ago

ssasso commented 1 year ago

After upgrading to vagrant 2.3.6, SSH key authentication stopped working, and vagrant up keeps asking for the VM password.

==> sw: Waiting for machine to boot. This may take a few minutes...
DEBUG ssh: Checking key permissions: /root/.vagrant.d/insecure_private_key
 INFO interface: detail: SSH address: 192.168.121.5:22
 INFO interface: detail:     sw: SSH address: 192.168.121.5:22
    sw: SSH address: 192.168.121.5:22
 INFO interface: detail: SSH username: vagrant
 INFO interface: detail:     sw: SSH username: vagrant
    sw: SSH username: vagrant
 INFO interface: detail: SSH auth method: private key
 INFO interface: detail:     sw: SSH auth method: private key
    sw: SSH auth method: private key
DEBUG ssh: Checking key permissions: /root/.vagrant.d/insecure_private_key
 INFO ssh: Attempting SSH connection...
 INFO ssh: Attempting to connect to SSH...
 INFO ssh:   - Host: 192.168.121.5
 INFO ssh:   - Port: 22
 INFO ssh:   - Username: vagrant
 INFO ssh:   - Password? false
 INFO ssh:   - Key Path: ["/root/.vagrant.d/insecure_private_key"]
DEBUG ssh:   - connect_opts: {:auth_methods=>["none", "hostbased", "keyboard-interactive", "publickey"], :config=>false, :forward_agent=>false, :send_env=>false, :keys_only=>true, :verify_host_key=>:never, :password=>nil, :port=>22, :timeout=>15, :user_known_hosts_file=>[], :verbose=>:debug, :logger=>#<Logger:0x00007f373c3796f8 @level=0, @progname=nil, @default_formatter=#<Logger::Formatter:0x00007f373c379658 @datetime_format=nil>, @formatter=nil, @logdev=#<Logger::LogDevice:0x00007f373c379568 @shift_period_suffix=nil, @shift_size=nil, @shift_age=nil, @filename=nil, @dev=#<StringIO:0x00007f373c379770>, @binmode=false, @mon_data=#<Monitor:0x00007f373c379518>, @mon_data_owner_object_id=51760>>, :keys=>["/root/.vagrant.d/insecure_private_key"], :remote_user=>"vagrant", :keepalive=>true, :keepalive_interval=>5}

Password:

Logging in directly with SSH works fine, so both the VM and the key looks good.

ssh -i /root/.vagrant.d/insecure_private_key vagrant@192.168.121.5
Warning: Permanently added '192.168.121.5' (ECDSA) to the list of known hosts.
localhost#
localhost#

Vagrantfile:

Vagrant.configure("2") do |config|
  config.vm.provider :libvirt do |libvirt|
    libvirt.management_network_address = "192.168.121.0/24"
    libvirt.default_prefix = "vlan_vptx_"
  end
  config.vm.define "sw" do |sw|
    sw.vm.provider :libvirt do |domain|
      domain.management_network_mac = "084FA900000A"
      domain.qemu_use_session = false
    end
    sw.vm.box = "arista/veos"
    sw.vm.synced_folder ".", "/vagrant", id: "vagrant-root", disabled: true
    sw.ssh.insert_key = false
    sw.ssh.shell = "bash"
    sw.vm.guest = :freebsd

    sw.vm.provider :libvirt do |domain|
      domain.disk_bus = 'ide'
      domain.cpus = 2
      domain.memory = 2048
      domain.driver = "kvm"
    end

    sw.vm.network :private_network,
                  :libvirt__network_name => "vlan_vptx_1",
                  :libvirt__forward_mode => "veryisolated",
                  :libvirt__dhcp_enabled => false,
                  :libvirt__iface_name => "vgif_sw_1",
                  :autostart => true,
                  :auto_config => false
  end
end

Downgrading back to 2.3.4 solves the issue.

TonyApuzzo commented 1 year ago

Same problem with Windows 11 + Hyper-V. Guessing it is a core issue, not environment specific.

Affects old machines as well as newly provisioned on my system.

chrisroberts commented 1 year ago

This is a duplicate of #13171 and was fixed via #13194. The fix will be included in the next release which will be shipping towards the end of the week.

You can grab a nightly build for now which also includes the fix.

Cheers!