Conection aborted on when starting locally produced box

1,332 views
Skip to first unread message

jo...@norricorp.f9.co.uk

unread,
Sep 13, 2017, 5:08:40 AM9/13/17
to Vagrant
Vagrant 2.0.0
VirtualBox 5.1.26 
host is windows 10 pro.

So this is what I have done

iso file for mint 18.2
create new VM in virtualbox using iso. Install mint with vagrant as user.
Run VM in virtualbox, log on as vagrant with password of vagrant. Create .ssh folder in vagrant home, copy insecure_private_key to authorized_keys.

vagrant package to create box file, vagrant add to add box

vagrant init -m box_name

vagrant up gives this 
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Importing base box 'mint182_vagrant'...
==> default: Matching MAC address for NAT networking...
==> default: Setting the name of the VM: mint182_base_default_1505291152265_43039
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
    default: Adapter 1: nat
==> default: Forwarding ports...
    default: 22 (guest) => 2222 (host) (adapter 1)
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
    default: SSH address: 127.0.0.1:2222
    default: SSH username: vagrant
    default: SSH auth method: private key
    default: Warning: Connection aborted. Retrying...
    default: Warning: Connection reset. Retrying...
    default: Warning: Connection aborted. Retrying...
    default: Warning: Connection reset. Retrying...
    default: Warning: Connection aborted. Retrying...
    default: Warning: Connection reset. Retrying...
    default: Warning: Connection aborted. Retrying...
    default: Warning: Remote connection disconnect. Retrying...
    default: Warning: Connection aborted. Retrying...

The last two lines then repeat until control-C

Looking in virtualbox, the VM is running. So I tried vagrant ssh
ssh_exchange_identification: read: Software caused connection abort

PS> vagrant ssh-config
Host default
  HostName 127.0.0.1
  User vagrant
  Port 2222
  UserKnownHostsFile /dev/null
  StrictHostKeyChecking no
  PasswordAuthentication no
  IdentityFile D:/Vagrant/insecure_private_key
  IdentitiesOnly yes
  LogLevel FATAL


Normally when I connect to a VM via ssh, I use putty. And that is the only ssh I have on the PC. No ssh on command line. But I can open the Ubuntu on windows app which gives

/mnt/d/Vagrant_examples/mint182_base$ ssh -p2222 vag...@127.0.0.1
ssh_exchange_identification: Connection closed by remote host

I believe this is supposed to ask for a password.

So I am obviously doing something wrong. Does anyone have any ideas?

Regards,
John


Alvaro Miranda Aguilera

unread,
Sep 13, 2017, 6:26:59 AM9/13/17
to vagra...@googlegroups.com
hello

log in to the console using virtualbox, log into the vm as vagrant user and try to ssh

ssh vagrant@localhost

does that works?

Maybe there is no ssh server, or there is a firewall

there are some permissions to be set on .ssh directory (0700) and the files should be 0600

but check if you can ssh from the guest locally

--
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/949d2b40-f248-4f29-a18c-bc70eeed9ff3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Alvaro

jo...@norricorp.f9.co.uk

unread,
Sep 13, 2017, 9:07:51 AM9/13/17
to Vagrant
Hi Alvaro,
so yes - I needed to install the ssh server - thought that was part of default build.
Added that to the base, repackaged, added the box and vagrant up.

Different result. 
Until timeout, get "Warning: Authentication failure. Retrying..." messages. VM is up and running.
If I try to use vagrant ssh, then I get a password prompt.

Which suggests that my key is not working. I have the .ssh and authorized_keys permissions correct. Could it be end of line problems? Looking at authorized_keys in vi, there are no control characters. So don't think that is a problem.

Therefore my insecure_private_key does not appear to be working.

As part of making my own box, do I need to add a /vagrant directory for shared folders? Reading the notes. I did wonder if vagrant added this but I do not have a /vagrant folder.

Regards,
John


Alvaro Miranda Aguilera

unread,
Sep 13, 2017, 9:17:19 AM9/13/17
to vagra...@googlegroups.com
Hello

Share the scripts you are using so we can review.

Whats the OS you are using there?



also have a look at packer.io that can be used to build vms.

ie:


--
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.

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



--
Alvaro

jo...@norricorp.f9.co.uk

unread,
Sep 13, 2017, 9:48:07 AM9/13/17
to Vagrant
There are no scripts. The host is windows, the guest is mint.
I did not use packer because I wanted to try it manually to understand what needed to be done and what can go wrong. (Certainly get the "wrong" bit!).
My Vagrantfile is basic
PS D:\Vagrant_examples\mint182_base> cat Vagrantfile
Vagrant.configure("2") do |config|
  config.vm.box = "mint182_vagrant"
        config.vm.provider "virtualbox" do |v|
                v.gui = true
        end
end


Alvaro Miranda Aguilera

unread,
Sep 13, 2017, 9:55:26 AM9/13/17
to vagra...@googlegroups.com
sorry, maybe i wasn't clear

can you share the commands you are doing in he guest for the ssh key please.

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.

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



--
Alvaro

jo...@norricorp.f9.co.uk

unread,
Sep 13, 2017, 10:15:47 AM9/13/17
to Vagrant
I think I have realised what I have done. I put the insecure_private_key (on host) in authorized_keys file (on guest). And normally I would put the public key in that file.
In which case, how does the public key get there. And where is the public key?
I suppose this is the value in doing this from scratch by hand. It throws up these fundamental questions.

Alvaro Miranda Aguilera

unread,
Sep 13, 2017, 10:19:03 AM9/13/17
to vagra...@googlegroups.com
This is the key that need to go to .ssh/authorized_keys


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.

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



--
Alvaro

jo...@norricorp.f9.co.uk

unread,
Sep 13, 2017, 10:34:26 AM9/13/17
to Vagrant
Many thanks Alvaro. My book certainly did not cover that and I would not have found it.

Going back to a previous question on shared drives. Is it up to me to create a /vagrant folder on the guest?


Alvaro Miranda Aguilera

unread,
Sep 13, 2017, 1:13:21 PM9/13/17
to vagra...@googlegroups.com
/vagrant is the default shared folder, so if your guest is virtualbox, and virtualbox additions is installed on host/guest then will work

vagrant will create /vagrant on guest.

please, feel free to share questions, and if you think something should be easily available on the website but is not, or its not where you think should be, please say so, we can review and update documentation if required.

My personal involvement with Vagrant was in the very same way, and now after some time i know more, but is always good have the documentation up to date

:)

Alvaro.

On Wed, Sep 13, 2017 at 4:34 PM, <jo...@norricorp.f9.co.uk> wrote:
Many thanks Alvaro. My book certainly did not cover that and I would not have found it.

Going back to a previous question on shared drives. Is it up to me to create a /vagrant folder on the guest?


--
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.

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



--
Alvaro

jo...@norricorp.f9.co.uk

unread,
Sep 13, 2017, 2:24:37 PM9/13/17
to Vagrant
Thank you so much for your help Alvaro.
I did actually try creating the /vagrant directory in the VM from which I made the box and when I run it, there was a complaint when it made /vagrant.
Not sure if this is a bug because though the output lists the command, it gives no output.

==> default: Machine booted and ready!
==> default: Checking for guest additions in VM...
==> default: Mounting shared folders...
    default: /vagrant => D:/Vagrant_examples/mint182_base
The following SSH command responded with a non-zero exit status.
Vagrant assumes that this means the command failed!
mkdir -p /vagrant
Stdout from the command:

Stderr from the command:
PS D:\Vagrant_examples\mint182_base>

So I am guessing that when it created /vagrant, the output (either stdout or stderr) was "already exists" but this is not displayed.
No problems though, I can remove /vagrant in the original VM and create a new box.

Alvaro Miranda Aguilera

unread,
Sep 13, 2017, 2:33:18 PM9/13/17
to vagra...@googlegroups.com
mkdir -p will exit zero if dir exists so not an issue

try this

vagrant ssh
sudo su -


mkdir -p /thisdir ; echo $?
mkdir -p /thisdir ; echo $?

in both cases echo $? should be zero

does the vm have guest additions installed?

you can test adding shared folder over virtualbox gui and rebooting the vm


--
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.

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



--
Alvaro

jo...@norricorp.f9.co.uk

unread,
Sep 15, 2017, 9:54:19 AM9/15/17
to Vagrant
Hi Alvaro,
sorry for the delay in getting back.
So after vagrant up which leaves the VM in a running state but with the message
              ==> default: Mounting shared folders...
                      default: /vagrant => D:/Vagrant_examples/mint182_base
                     The following SSH command responded with a non-zero exit status.
                     Vagrant assumes that this means the command failed!
                            mkdir -p /vagrant
                            Stdout from the command:

                            Stderr from the command:

I then run vagrant ssh. /vagrant was missing (just to add, I removed it from base and re-packaged, re-boxed). 
Running mkdir -p /vagrant gave
           mkdir: cannot create directory ‘/vagrant’: Permission denied

Which makes sense because root directory is 755. When I created it on the base, I used sudo.
So vagrant is trying to create /vagrant but not using sudo so how does it actually work. Or how can it expect it to work?

Regards,
John 





Alvaro Miranda Aguilera

unread,
Sep 15, 2017, 10:05:31 AM9/15/17
to vagra...@googlegroups.com
when you created your box, did you add Vagrant user to the sudoer file so can run commands as root without a password?

Can you share the box?

--
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.

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



--
Alvaro

jo...@norricorp.f9.co.uk

unread,
Sep 15, 2017, 11:19:18 AM9/15/17
to Vagrant
OK, vagrant is added to the sudo file as a user that does not require a password to run as root.
But the mkdir vagrant command still requires sudo to proceed it. And, according to the output, vagrant up is running "mkdir -p /vagrant", not "sudo mkdir -p /vagrant". Or does the output just leave off sudo?


Reply all
Reply to author
Forward
Message has been deleted
0 new messages