葛西です。ブログを書きます。

私用メモです。葛西はニックネームです。

node.jsの勉強/参考書を片手にpcの設定作業/vagrantのCentOSにログインした

 vagrantをインストールして、vagrant initで以下の通り入力。

#config.vm.box = "base"
config.vm.box = "puphpet/centos65-x64"

 

vagrant upでvagrantCentOSを起動したら、次のエラーが表示された。

 $ vagrant up

Bringing machine 'default' up with 'virtualbox' provider...

==> default: Importing base box 'puphpet/centos65-x64'...

==> default: Matching MAC address for NAT networking...

==> default: Checking if box 'puphpet/centos65-x64' is up to date...

==> default: Setting the name of the VM: Vagrant_default_1472563241044_8922

==> default: Clearing any previously set network interfaces...

==> default: Preparing network interfaces based on configuration...

    default: Adapter 1: nat

==> default: Forwarding ports...

    default: 22 (guest) => 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:

    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: 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...

    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...

    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...

    default: Warning: Authentication failure. Retrying...

Timed out while waiting for the machine to boot. This means that

Vagrant was unable to communicate with the guest machine within

the configured ("config.vm.boot_timeout" value) time period.

 

If you look above, you should be able to see the error(s) that

Vagrant had when attempting to connect to the machine. These errors

are usually good hints as to what may be wrong.

 

If you're using a custom box, make sure that networking is properly

working and you're able to connect to the machine. It is a common

problem that networking isn't setup properly in these boxes.

Verify that authentication configurations are also setup properly,

as well.

 

If the box appears to be booting properly, you may want to increase

the timeout ("config.vm.boot_timeout") value.

 

 

新しいsshキーを使ってOSにログインしようとしてタイムアウトしてしまったみたいだ。

ここでは勉強として、vagrantのログを読んでみようと思ってネットを検索したところ、vagrantコマンドを実行する時、文頭にログ出力の文字列を加えて実行すればターミナル上にログが出力されるらしいことが分かった。

VAGRANT_LOG=info vagrant up

さっそく以下のコマンドでOSを破棄した所、思ったよりも沢山ログが出力された。

VAGRANT_LOG=info vagrant destory

再び、VAGRANT_LOG=info vagrant upでOSを起動して、ターミナルに出力されたログを見ていると以下の記述が沢山あった。

INFO subprocess: Command not in installer, restoring original environment...

INFO ssh: Attempting to correct key permissions to 0600

INFO ssh: Attempting SSH connection...

INFO ssh: Attempting to connect to SSH...

INFO ssh:   - Host: 127.0.0.1

INFO ssh:   - Port: 2222

INFO ssh:   - Username: vagrant

INFO ssh:   - Password? false

INFO ssh:   - Key Path: ["/Users/Documents/Vagrant/.vagrant/machines/default/virtualbox/private_key"]

INFO ssh: SSH not ready: #<Vagrant::Errors::SSHAuthenticationFailed: SSH authentication failed! This is typically caused by the public/private

keypair for the SSH user not being properly set on the guest VM. Please

verify that the guest VM is setup with the proper public key, and that

the private key path for Vagrant is setup properly as well.>

よく分からないのでそっ閉じしたい気分だが、雰囲気からたぶんpassword?falseとなっているので、passwordを指定しない状態でログインしようとしてエラーとなり、接続ができなかったのだろう。

 

ちなみにvagrant statusでタイムアウト後の状態をみるとこんな感じ。

$ vagrant status

Current machine states:

 

default                   running (virtualbox)

 

The VM is running. To stop this VM, you can run `vagrant halt` to

shut it down forcefully, or you can run `vagrant suspend` to simply

suspend the virtual machine. In either case, to restart it again,

simply run `vagrant up`.

 

起動しているみたい。

 

vagrant sshssh接続し、username/password=vagrant/vagrantでログイン出来た。