そういえば最近ドキュメント作ってばっかだ・・・
久々に色々やってみるとしよう
#まず、vagrantでCentOS7環境作るかな。
つまずかなければ即終了、のハズ。レッツトライ
vagrantが古いと色々問題があることが多い気がするので、事前に最新にしておいて・・・
$ vagrant --version
Vagrant 1.9.5
あ、公式のboxがあるみたい
$ 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.
書き書きするぜ
$ vi Vagrantfile
Vagrantfile
## 以下のコメントを外す
config.vm.network "private_network", ip: "192.168.33.10"
あとはお祈り
$ 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
よしゃー、とりあえず普通にうまくいった
バージョンを確認してみる。
$ vagrant ssh
[vagrant@localhost ~]$ cat /etc/redhat-release
CentOS Linux release 7.3.1611 (Core)
OKぽい
##その他設定、必要に応じて
###SSHのパスワード認証を許容する
$ sudo vi /etc/ssh/sshd_config
/etc/ssh/sshd_config
-PasswordAuthentication no
+PasswordAuthentication yes
$ sudo systemctl restart sshd.service
###SELinuxの無効化
デフォルトの確認
$ getenforce
Enforcing
無効にする
$sudo vi /etc/selinux/config
/etc/selinux/config
-SELINUX=enforcing
+SELINUX=disabled
再起動後、再確認する
$ getenforce
Disabled