LoginSignup
13
9

More than 5 years have passed since last update.

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

Posted at

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

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

確認

vagrant_01.png

おや?

vagrant_02.png

おやおや?

vagrant_03.png

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

同一ディレクトリの別のファイル

確認のため、別のファイルのアクセス許可を見てみましょう。

vagrant_04.png

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

修正

vagrant_03_2.png

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

vagrant_05.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で接続できました。

13
9
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
13
9