Vagrant installation Centos7
Vagrant installation Centos7
First prepare VirtualBox , the current experimental version is: 7.0.4-154605-Win;
Download the Vagrant windows version again: current experimental version: vagrant_2.3.4_windows_i686
If you are prompted during the installation of VirtualBox that Microsoft Visual C++ 2019 Redistributable is missing: you can download and install it separately.
During the installation process, you are prompted to restart your computer. Let’s start installing Centos7 .
1: Create a new directory for running Centos7;
2: Go to the official website to download the Centos7 VirtualBox image, copy the downloaded file to step 1, and rename it to a short name, such as centos7.box;
https://app.vagrantup.com/centos/boxes/7/versions/2004.01/providers/virtualbox.box
3: Open the cmd command line, cd to the directory in step 1, and execute: vagrant box add --name 'centos7' centos7.box;
D:\mix>vagrant box add --name 'centos7' centos7.box
==> box: Box file was not detected as metadata. Adding it directly...
==> box: Adding box 'centos7' (v0) for provider:
box: Unpacking necessary files from: file://D:/mix/centos7.box
box:
==> box: Successfully added box 'centos7' (v0) for 'virtualbox'!
4: vagrant init centos7: initialize centos7:
At this time, a Vagrantfile file will be created in the current directory;
D:\mix>vagrant init centos7
A Vagrantfile
has been placed in this directory. You are now
ready to vagrant up
your first virtual environment! Please read
the comments in the Vagrantfile as well as documentation on
vagrantup.com
for more information on using Vagrant.
5:vagrant up:
At this point: Open virtualbox: you can see that a centos virtual machine has been instantiated:
6: ssh connect to the virtual machine:
vagrant ssh
At this point, a centos virtual machine environment is successfully running;
7: View status: vagrant status;
8: Stop running: vagrant hault;
9: If you want to delete the virtual machine: execute: vagrant destroy;
10: Modify root password: The default password of root is vagrant, and the default password of vagrant is also vagrant.
[vagrant@localhost ~]$ sudo passwd root
Changing password for user root.
New password:
BAD PASSWORD: The password is a palindrome
Retype new password:
passwd: all authentication tokens updated successfully.
11: Modify the configuration to enable remote connection:
sudo vi /etc/ssh/sshd_config
change PermitRootLogin to yes; change PasswordAuthentication to yes
Restart the sshd service: sudo systemctl restart sshd
12: Make sure you can ping the centos virtual machine and use tools such as FinalShell to connect to the virtual machine;