Windows10でvagrant up すると  Warning: Remote connection disconnect. Retrying... が出て time out する件

Windows10の仕事マシンで久々にVagrantと戯れようと思い、最新版（2.1.1）をインストール。VirtualBoxも用意して、OSはひとまずUbuntuでいいかなー

```:cmd.exe
vagrant init ubuntu/trusty64
vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Importing base box 'ubuntu/trusty64'...
==> default: Matching MAC address for NAT networking...
==> default: Checking if box 'ubuntu/trusty64' is up to date...
==> default: Setting the name of the VM: vagrant_example_default_1527217108538_19840
==> default: Clearing any previously set forwarded ports...
==> 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:
    default: Vagrant insecure key detected. Vagrant will automatically replace
    default: this with a newly generated keypair for better security.
    default:
    default: Inserting generated public key within guest...
    default: Removing insecure key from the guest if it's present...
    default: Key inserted! Disconnecting and reconnecting using new SSH key...
    default: Warning: Remote connection disconnect. Retrying...
    default: Warning: Remote connection disconnect. Retrying...
    default: Warning: Remote connection disconnect. Retrying...
    ...
Timed out while waiting for the machine to boot. 略
```
```
＿人人人人人人人人人人人人＿
＞　vagrant up できない！　＜
￣Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y￣
```

なお、VMは起動している模様。SSHで接続できない。


## 環境

* Windows 10 Pro (64bit)
* Vagrant 2.1.1
* VirtualBox 5.2.12

あと、社内のActiveDirectoryに参加してます。

## 時間がない人向け TL;DL
```
(Vagrantfileのあるディレクトリ)\.vagrant\machines\default\virtualbox\private_key
```
この`private_key`のアクセス権を修正してやりましょう。

## 経緯
`vagrant up`時のこのあたりのログが怪しいですね。

```
    default: Vagrant insecure key detected. Vagrant will automatically replace
    default: this with a newly generated keypair for better security.
    default:
    default: Inserting generated public key within guest...
    default: Removing insecure key from the guest if it's present...
    default: Key inserted! Disconnecting and reconnecting using new SSH key...
    default: Warning: Remote connection disconnect. Retrying...
```

Vagrant 1.7 より、公式のinsecureなkeyを使っているBOXは`vagrant up`時にkeypairに差し替えられるとのことなんですが、どうやら差し替え後にSSHで接続できていない模様。

困ったときは公式を参照ということで、GitHubリポジトリを覗いてみるとissueがありますね。

[Vagrant up fails with Warning: Remote connection disconnect. Retrying... #9834]
(https://github.com/hashicorp/vagrant/issues/9834)

private_keyの権限がおかしいから修正したら動くよ！とのこと。

## 確認

![vagrant_01.png](https://qiita-image-store.s3.amazonaws.com/0/135155/0d3e53f0-a480-489f-9c3c-af4ea1d1afea.png)

おや？

![vagrant_02.png](https://qiita-image-store.s3.amazonaws.com/0/135155/49038ef5-93ec-7edc-c7bc-559405bf1ca1.png)

おやおや？

![vagrant_03.png](https://qiita-image-store.s3.amazonaws.com/0/135155/a917f9b3-31bd-a165-7857-d74a70ae07f2.png)

あらあら、何か物足りませんね。

### 同一ディレクトリの別のファイル
確認のため、別のファイルのアクセス許可を見てみましょう。

![vagrant_04.png](https://qiita-image-store.s3.amazonaws.com/0/135155/88bc77fc-60b2-9927-5b5b-c17e152b27c4.png)

SYSTEMやAdministratorsグループが存在しますね。ユーザーもローカルユーザーではなく、ログインしているドメインユーザーです。

### 修正
![vagrant_03_2.png](https://qiita-image-store.s3.amazonaws.com/0/135155/dadfc644-718e-0b5e-8f38-428606aa5643.png)

「継承の有効化」をポチってやると、親フォルダのアクセス許可エントリを継承するようです。

![vagrant_05.png](https://qiita-image-store.s3.amazonaws.com/0/135155/f3a9c10b-df83-d7bc-ff2a-b308a017fd99.png)

治りました。

## 再び vagrant up
先程の`vagrant up`でVMは起動しているので、先に`vagrant halt`しておきましょう。

```:cmd.exe
$ vagrant up                                                                                 
Bringing machine 'default' up with 'virtualbox' provider...                                  
==> default: Checking if box 'ubuntu/trusty64' is up to date...                              
==> default: Clearing any previously set forwarded ports...                                  
==> 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: Machine booted and ready!                                                       
==> default: Checking for guest additions in VM...                                           
    default: The guest additions on this VM do not match the installed version of            
    default: VirtualBox! In most cases this is fine, but in rare cases it can                
    default: prevent things such as shared folders from working properly. If you see         
    default: shared folder errors, please make sure the guest additions within the           
    default: virtual machine match the version of VirtualBox you have installed on           
    default: your host and reload your VM.                                                   
    default:                                                                                 
    default: Guest Additions Version: 4.3.36                                                 
    default: VirtualBox Version: 5.2                                                         
==> default: Mounting shared folders...                                                      
    default: /vagrant => C:/Users/##########/vagrant_example                                
==> default: Machine already provisioned. Run `vagrant provision` or use the `--provision`   
==> default: flag to force provisioning. Provisioners marked to run always will still run.   
```

無事、`vagrant up`できたようです。`vagrant ssh`してみましょう。

```:cmd.exe
vagrant ssh
Welcome to Ubuntu 14.04.5 LTS (GNU/Linux 3.13.0-149-generic x86_64)

 * Documentation:  https://help.ubuntu.com/

  System information as of Fri May 25 06:25:30 UTC 2018

  System load:  0.29              Processes:           80
  Usage of /:   3.6% of 39.34GB   Users logged in:     0
  Memory usage: 24%               IP address for eth0: 10.0.2.15
  Swap usage:   0%

  Graph this data and manage this system at:
    https://landscape.canonical.com/

  Get cloud support with Ubuntu Advantage Cloud Guest:
    http://www.ubuntu.com/business/services/cloud

0 packages can be updated.
0 updates are security updates.

New release '16.04.4 LTS' available.
Run 'do-release-upgrade' to upgrade to it.


vagrant@vagrant-ubuntu-trusty-64:~$
```

無事、SSHで接続できました。