最近在弄 puppet-vagrant-apache2-php7 這個 repository 的 Vagrant box 的時候拿 Ubuntu 16.04 當 base,結果 build 完要 vagrant run 的時候發現無法登陸 …
預設 Vagrant box 都是 vagrant/vagrant,之前用習慣了突然不能登入覺得有點錯愕。
後來查了一下 pull box 都會放在家目錄的 ~/.vagrant.d/boxes 這個位置。
所有 pull 過的 box 都會放在這個位置,以 Ubuntu 16.04 的 20171221.0.0 版本的話,會在這個位置
~/.vagrant.d/boxes/ubuntu-VAGRANTSLASH-xenial64/20171221.0.0/virtualbox
密碼就藏在這個位置底下的 Vagrantfile
# Front load the includes
include_vagrantfile = File.expand_path("../include/_Vagrantfile", __FILE__)
load include_vagrantfile if File.exist?(include_vagrantfile)
Vagrant.configure("2") do |config|
config.vm.base_mac = "0293061CA64F"
config.ssh.username = "ubuntu"
config.ssh.password = "379a8188cba8c5e64b9a429f"
config.vm.provider "virtualbox" do |vb|
vb.customize [ "modifyvm", :id, "--uart1", "0x3F8", "4" ]
vb.customize [ "modifyvm", :id, "--uartmode1", "file", File.join(Dir.pwd, "ubuntu-xenial-16.04-cloudimg-console.log") ]
end
end
原來 Ubuntu 的 Vagrant box 用這麼隨機的密碼 …
要改密碼的話可以在 build Vagrant box 的時候用 chpasswd 來改。
$ echo "ubuntu:ironman" | sudo chpasswd
