開発環境の構築


初めてのVagrant - 再挑戦 -

初めてのサーバ・プロビジョニング - 再挑戦 -

前回はvagrant upでエラーが発生していました。
何が原因かよくわかりませんが、vagrant@127.0.0.1: Permission denied (publickey).というメッセージが出ていますので、何かの権限が足りないようです。
根拠はありませんが、コマンドプロンプトを管理者権限で起動して試してみることにします。

> e: ↵
> cd E:¥MyDocuments¥Project¥Python¥vagrant_test ↵
> vagrant init ubuntu/disco64 ↵
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.
> vagrant up ↵
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Importing base box 'ubuntu/disco64'...
==> default: Matching MAC address for NAT networking...
==> default: Checking if box 'ubuntu/disco64' version '20190816.0.0' is up to date...
==> default: A newer version of the box 'ubuntu/disco64' for provider 'virtualbox' is
==> default: available! You currently have version '20190816.0.0'. The latest is version
==> default: '20190819.0.0'. Run `vagrant box update` to update.
==> default: Setting the name of the VM: vagrant_test_default_1566211372238_99272
==> 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: Running 'pre-boot' VM customizations...
==> 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: Connection aborted. 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: Mounting shared folders...
    default: /vagrant => E:/MyDocuments/Project/Python/vagrant_test
> vagrant ssh ↵
Welcome to Ubuntu 19.04 (GNU/Linux 5.0.0-25-generic x86_64)

 * Documentation:  https://help.ubuntu.com
 * Management:     https://landscape.canonical.com
 * Support:        https://ubuntu.com/advantage

  System information as of Mon Aug 19 11:28:48 UTC 2019

  System load:  0.01              Processes:             113
  Usage of /:   11.5% of 9.63GB   Users logged in:       0
  Memory usage: 17%               IP address for enp0s3: 10.0.2.15
  Swap usage:   0%


0 updates can be installed immediately.
0 of these updates are security updates.


Welcome to Ubuntu 19.04 (GNU/Linux 5.0.0-25-generic x86_64)

 * Documentation:  https://help.ubuntu.com
 * Management:     https://landscape.canonical.com
 * Support:        https://ubuntu.com/advantage

  System information as of Mon Aug 19 11:28:48 UTC 2019

  System load:  0.01              Processes:             113
  Usage of /:   11.5% of 9.63GB   Users logged in:       0
  Memory usage: 17%               IP address for enp0s3: 10.0.2.15
  Swap usage:   0%


0 updates can be installed immediately.
0 of these updates are security updates.


vagrant@ubuntu-disco:~$ ls -la ↵
total 32
drwxr-xr-x 5 vagrant vagrant 4096 Aug 19 10:47 .
drwxr-xr-x 4 root    root    4096 Aug 19 10:47 ..
-rw-r--r-- 1 vagrant vagrant  220 Aug 16 03:16 .bash_logout
-rw-r--r-- 1 vagrant vagrant 3771 Aug 16 03:16 .bashrc
drwx------ 2 vagrant vagrant 4096 Aug 19 10:47 .cache
drwx------ 3 vagrant vagrant 4096 Aug 19 10:47 .gnupg
-rw-r--r-- 1 vagrant vagrant  807 Aug 16 03:16 .profile
drwx------ 2 vagrant vagrant 4096 Aug 19 10:47 .ssh
vagrant@ubuntu-disco:~$ exit ↵
logout
Connection to 127.0.0.1 closed.
> vagrant halt ↵
==> default: Attempting graceful shutdown of VM...
> vagrant destroy ↵
    default: Are you sure you want to destroy the 'default' VM? [y/N] y
==> default: Destroying VM and associated drives...

今回は成功したようです。
どうやら、管理者権限でvagrantを実行しないと正しく動作しないようです。