Vagrant ssh non functional if box booted with vagrant up

33 views
Skip to first unread message

Marcus Povey

unread,
Mar 11, 2018, 8:28:16 AM3/11/18
to Vagrant
This is a weird one that I can't get to the bottom of...

Linux vagrant box, booted and provisioned OK.

If the box is spun up using "vagrant up", subsequent calls to "vagrant ssh" will fail with "invalid public key". Vagrant ssh-config points to the insecure key (correct).
I have also tried removing "config.ssh.insert_key = false" and using the secure generated keys. Same effect.

I've also tried specifying a host in my ~/.ssh/config:

Host 127.0.0.1
User vagrant
IdentityFile ~/.vagrant.d/insecure_private_key
Port 2222
IdentitiesOnly yes

SSH from the console also fails.

Interestingly, vagrant up --provision will connect and run the provisioning script, so at some point vagrant is able to connect via ssh, although after the box has booted "vagrant halt" can no longer connect.

Now, here's the really weird part...

If I spin up the box manually using the VirtualBox GUI, after the machine is booted both ssh and "vagrant ssh" work with no problem. "Vagrant halt" is able to connect and everything works as expected (although I have to manually log in and mount my sync dir)

So, it very much seems that at some stage "vagrant up" is changing the ssh key somehow, although when boot the box using virtualbox and log in, my authorized_keys file for the vagrant user is correct, and the date on it shows it has not been modified since the box was originally provisioned.

Vagrant 2.0.2, on an Ubuntu host. Virtualbox 5.2

Any ideas what's going on?

Alvaro Miranda Aguilera

unread,
Mar 11, 2018, 2:55:34 PM3/11/18
to vagra...@googlegroups.com
share a zip with the project or the Vagrantfile if you don' have any provision.

I would say

1. try like this

vagrant destroy
vagrant up --no-provision
vagrant ssh
vagrant reload

works?

if yes, something is breaking this

2. try with a different box

vagrant destroy
vagrant up --no-provision
vagrant ssh
vagrant reload

works?

then something is broken with the box


Alvaro


--
This mailing list is governed under the HashiCorp Community Guidelines - https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list.
 
GitHub Issues: https://github.com/mitchellh/vagrant/issues
IRC: #vagrant on Freenode
---
You received this message because you are subscribed to the Google Groups "Vagrant" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vagrant-up+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vagrant-up/ef4ef8bf-1ab6-44fb-83fd-38df24f5fe35%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Alvaro

Marcus Povey

unread,
Mar 12, 2018, 6:17:31 AM3/12/18
to Vagrant
Hi, thanks for getting back to me.

I tried what you said, both on my own computer and my colleague's computer. Both cases after bringing up the box with no provisioning, vagrant ssh failed.

Here's the Vagrantfile:

Vagrant.configure("2") do |config|
  config.ssh.insert_key = false 
  
  config.vm.box = "ubuntu/xenial64"

  config.vm.boot_timeout = 600

  config.vm.hostname = "twelveandus"
  config.vm.network :private_network, ip: "192.168.33.34"

  config.vm.synced_folder ".", "/home/vagrant/"

  config.vm.provision :shell, path: "vagrant/bootstrap.sh"
  config.vm.provision :shell, path: "vagrant/startup.sh", run: "always"

  config.vm.provider "virtualbox" do |v|
    v.memory = 2048
  end

end
To unsubscribe from this group and stop receiving emails from it, send an email to vagrant-up+...@googlegroups.com.



--
Alvaro

Alvaro Miranda Aguilera

unread,
Mar 13, 2018, 3:54:01 AM3/13/18
to vagra...@googlegroups.com
Hello

Well what I said was basically start minimal and do a change as the time

start with a Vagrantfile like this:

Vagrant.configure("2") do |config|

  #config.ssh.insert_key = false 

  

  #config.vm.box = "ubuntu/xenial64"

  config.vm.box = "hashicorp/precise64"


  #config.vm.boot_timeout = 600


  #config.vm.hostname = "twelveandus"

  #config.vm.network :private_network, ip: "192.168.33.34"


  #config.vm.synced_folder ".", "/home/vagrant/"


  #config.vm.provision :shell, path: "vagrant/bootstrap.sh"

  #config.vm.provision :shell, path: "vagrant/startup.sh", run: "always"


  #config.vm.provider "virtualbox" do |v|

  #  v.memory = 2048

  #end


end




Does this work ?

if yes, maybe the box you are using is broken.

try as is, then try with the box you want to use

and test one line of the configuration of the time until you find where it breaks

Alvaro

To unsubscribe from this group and stop receiving emails from it, send an email to vagrant-up+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vagrant-up/a42302b8-e1c2-4793-8efd-b48108be8cf6%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
Alvaro

Marcus Povey

unread,
Mar 13, 2018, 9:46:35 AM3/13/18
to Vagrant
Hi, thank you for your help.

I've done a little bit of digging, as you suggested.

The problem appears to be with the synced_folder entry. Before this, I could ssh in, if the box is provisioned with this line, SSH is no longer possible. This with the ubuntu/xenial box, updated to latest.

If I switch to the hashicorp/precise64 box, I *can* ssh in, although it falls back to password. If I don't have the synced_folder line on the hashicorp box I am able to ssh in with the public key (i.e. it doesn't fall back), so it looks like the hashicorp build has better recovery, but the fundamental problem is still there (and indeed, vagrant halt fails to connect to the box).

Marcus



--
Alvaro

Marcus Povey

unread,
Mar 13, 2018, 9:49:04 AM3/13/18
to Vagrant
Thought about this some more, and it's obvious what's going on...

authorized_keys is in /home/vagrant, so *obviously*, when I mount my working directory over that, it becomes inaccessible. *doh*

Of course now, I'm running into a separate problem, whereby if I mount to /vagrant, mounting doesn't take place at all, but baby steps...

Marcus Povey

unread,
Mar 13, 2018, 10:22:40 AM3/13/18
to Vagrant
... and I think this is down to vagrant-vbguest failing, for some reason the guest OS is becoming readonly randomly during boot. No clue what's going on there....

Alvaro Miranda Aguilera

unread,
Mar 13, 2018, 4:11:00 PM3/13/18
to vagra...@googlegroups.com
for xenial if you want shared folder and the box doesn't have it, use a different box will be easier

ie




To unsubscribe from this group and stop receiving emails from it, send an email to vagrant-up+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vagrant-up/8103573c-f1be-4951-a67b-e4ef0ad8d9e4%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
Alvaro

Marcus Povey

unread,
Mar 14, 2018, 6:56:42 AM3/14/18
to Vagrant
Thanks, I've switched boxes. This also *seems* to have solved the issue where the VM would randomly spew out IO errors and become read only during provisioning.



--
Alvaro

Reply all
Reply to author
Forward
0 new messages