hashicorp / vagrant

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

vagrant ssh vs ssh vagrant@host -i .vagrant/machines/default/libvirt/private_key #13306

Closed derhelge closed 6 months ago

derhelge commented 7 months ago

My observed problem is that somestimes vagrant ssh does not work but ssh vagrant@host does. The problem usually occurs after a host has been started "briefly" (a few seconds to minutes). After some time (several minutes) vagrant ssh works again.

➜ firehol vagrant ssh
The provider for this Vagrant-managed machine is reporting that it is not yet ready for SSH. [...] ➜ firehol ssh vagrant@192.168.122.211 -i .vagrant/machines/default/libvirt/private_key Last login: Thu Dec 7 15:18:22 2023 from 192.168.122.1 vagrant@firehol:~$ ➜ firehol vagrant ssh
The provider for this Vagrant-managed machine is reporting that it is not yet ready for SSH. [...]

Debug output

https://gist.github.com/derhelge/5744a6bc37ee15e25dcd519e22611828

Vagrant version

Vagrant 2.2.19

Host operating system

Fedora 38 Linux

Guest operating system

generic/ubuntu2204

Vagrantfile

# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
  config.vm.box = "generic/ubuntu2204"
  config.vm.hostname = 'firehol'
end
chrisroberts commented 6 months ago

When Vagrant runs ssh it will request the information from the provider (which can be seen here) and the provider will return the required information for establishing the ssh connection. If the provider has not yet completed setting up the guest, it may return an error during this time to indicate that not all information is ready. The underlying cause for why the error is being generated will be specific to a given provider.

Cheers!