Tutorial on using VirtualBox + Vagrant to install CentOS 7 on Windows

Source: Internet
Author: User
Tags chmod ssh centos

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.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.