まず、vagrantでCentOS7環境作るかな。

そういえば最近ドキュメント作ってばっかだ・・・ :ghost:
久々に色々やってみるとしよう :sunglasses:

#まず、vagrantでCentOS7環境作るかな。

つまずかなければ即終了、のハズ。レッツトライ:baby_tone2:
vagrantが古いと色々問題があることが多い気がするので、事前に最新にしておいて・・・

```console
$ vagrant --version
Vagrant 1.9.5
```

あ、[公式のbox](https://atlas.hashicorp.com/centos)があるみたい:thumbsup_tone2:

```console
$ vagrant init centos/7 
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.
```

書き書きするぜ:writing_hand_tone2:

```console
$ vi Vagrantfile
```

```sh:Vagrantfile
## 以下のコメントを外す
config.vm.network "private_network", ip: "192.168.33.10"
```

あとはお祈り:pray_tone2:

```console
$ vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Box 'centos/7' could not be found. Attempting to find and install...
    default: Box Provider: virtualbox
    default: Box Version: >= 0
==> default: Loading metadata for box 'centos/7'
    default: URL: https://atlas.hashicorp.com/centos/7
==> default: Adding box 'centos/7' (v1704.01) for provider: virtualbox
    default: Downloading: https://atlas.hashicorp.com/centos/boxes/7/versions/1704.01/providers/virtualbox.box
==> default: Successfully added box 'centos/7' (v1704.01) for 'virtualbox'!
==> default: Importing base box 'centos/7'...
==> default: Matching MAC address for NAT networking...
==> default: Checking if box 'centos/7' is up to date...
==> default: Setting the name of the VM: vagrant_default_1497102623257_95887
==> default: Fixed port collision for 22 => 2222. Now on port 2200.
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
    default: Adapter 1: nat
    default: Adapter 2: hostonly
==> default: Forwarding ports...
    default: 22 (guest) => 2200 (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:2200
    default: SSH username: vagrant
    default: SSH auth method: private key
    default: Warning: Remote connection disconnect. Retrying...
    default: Warning: Connection reset. Retrying...
    default: Warning: Remote connection disconnect. Retrying...
    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: Machine booted and ready!
==> default: Checking for guest additions in VM...
    default: No guest additions were detected on the base box for this VM! Guest
    default: additions are required for forwarded ports, shared folders, host only
    default: networking, and more. If SSH fails on this machine, please install
    default: the guest additions and repackage the box to continue.
    default: 
    default: This is not an error message; everything may continue to work properly,
    default: in which case you may ignore this message.
==> default: Configuring and enabling network interfaces...
    default: SSH address: 127.0.0.1:2200
    default: SSH username: vagrant
    default: SSH auth method: private key
```

よしゃー、とりあえず普通にうまくいった :v_tone2:

バージョンを確認してみる。

```console
$ vagrant ssh
[vagrant@localhost ~]$ cat /etc/redhat-release
CentOS Linux release 7.3.1611 (Core) 
```
OKぽい:wink:


##その他設定、必要に応じて

###SSHのパスワード認証を許容する

```console
$ sudo vi /etc/ssh/sshd_config
```

```diff:/etc/ssh/sshd_config
-PasswordAuthentication no
+PasswordAuthentication yes
```

```console
$ sudo systemctl restart sshd.service
```
###SELinuxの無効化

デフォルトの確認

```console
$ getenforce
Enforcing
```

無効にする

```console
$sudo vi /etc/selinux/config
```

```diff:/etc/selinux/config
-SELINUX=enforcing
+SELINUX=disabled
```

再起動後、再確認する

```console
$ getenforce
Disabled
```