To use VirtualBox + Vagrant on Windows to install the CentOS 7 environment, you must install VirtualBox and Vagrant tools and download a box image file for CentOS 7.
1. Install the above tools. After downloading the box file, run the vagrant command to add the image to Vagrant:
Vagrant box add name path
The image is successfully added to Vagrant as follows:
II. Initialize the development environment
In Windows, create a folder dev on drive D and perform the following operations:
D: \ dev> vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> Default: Importing base box 'centos 7 '...
==> Default: Matching MAC address for NAT networking...
==> Default: Setting the name of the VM: dev_default_1458805394726_355
==> Default: Clearing any previously set network interfaces...
==> Default: Preparing network interfaces based on configuration...
Default: Adapter 1: nat
==> Default: Forwarding ports...
Default: 22 (guest) = & gt; 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: Authentication failure. Retrying...
Default: Warning: Authentication failure. Retrying...
Default: Warning: Authentication failure. Retrying...
Default: Warning: Authentication failure. Retrying...
Default: Warning: Authentication failure. Retrying...
Default: Warning: Authentication failure. Retrying...
Default: Warning: Authentication failure. Retrying...
Default: Warning: Authentication failure. Retrying...
Default: Warning: Authentication failure. Retrying...
The following commands are used:
$ Cd ~ /Dev # switch directories
$ Vagrant init hahaha # initialization
$ Vagrant up # Start the environment
But there is a problem, always prompt: default: Warning: Authentication failure. Retrying...
This is because SSH key is not configured in Windows. Do not worry. Use XShell to connect to the VM. The ssh address is 127.0.0.1: 2222 and the password is vagrant.
1. The vagrant user must exist, so the/home/vagrant directory must also exist.
2. Import the vagrant public key
Cd/home/vagrant
Sudo-u vagrant wget https://raw.githubusercontent.com/mitchellh/vagrant/master/keys/vagrant.pub-O. ssh/authorized_keys
Sudo-u vagrant chmod 700. ssh
Sudo-u vagrant chmod 600. ssh/authorized_keys
Sudo-u vagrant chown-R vagrant: vagrant. ssh
This step is done, as shown in the figure (click to see the big picture ):
Vagrant_authentication returns to the windows command line again, which is also the dev directory. Run vagrant up to start the VM:
D: \ dev> vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> Default: VirtualBox VM is already running.
The VM is successfully started.