2016-12-27 801 views
19

我试图通过Vagrant 1.9.1部署和运行Ubuntu 16.04 VM。 我使用的是Vagrantfile阿特拉斯:Vagrant的Ubuntu 16.04 vagrantfile默认密码

Ubuntu Xenial 16.04 Vagrantfile

我使用Debian拉伸作为主机操作系统。 Vagrant通过Vagrant网站上的.deb安装。

Vagrantfile确实运行和部署。我可以通过我的主机操作系统并使用'vagrant ssh'ssh进入虚拟机。不过,当我试图从外面进入时,我有一个小阻滞器。

此虚拟机中的默认用户名为'ubuntu',并且看起来设置了密码。但是,我不知道密码是什么,没有文档似乎有我正在寻找的信息。尝试通过虚拟机内的“passwd”设置密码要求输入当前密码。任何人都可以看到这是哪里?

所以我的大问题是这样的:有没有其他人部署这个相同的Vagrantfile,如果有的话,有谁知道默认用户的密码是什么?

+0

值得一提的是,这打破了用户的流浪标准/将两者默认为“流浪”。 https://www.vagrantup.com/docs/boxes/base.html – Ryre

回答

21

到写这篇的回答:从来没有人公开共享的ubuntu/xenial64流浪盒(见#1569237)用户ubuntu密码。

这没有必要。您可以:

  • 登录使用SSH密钥认证
  • 改变使用sudo passwd ubuntu密码(默认为ubuntu用户须藤的权限与NOPASSWD集)

其实,不仅可以,但你应该更改密码。

+1

感谢您链接到Launchpad错误报告! 通过的意见之后,我找到了一个链接到其他的Ubuntu 16.04 Vagrantfile我下载并测试: https://atlas.hashicorp.com/bento/boxes/ubuntu-16.04 这一个使用过的旧用户名和“流浪者/流浪者”的密码,这让我可以做我的测试无头痛。 :) – rmenes379

27

密码位于~/.vagrant.d/ubuntu-VAGRANTSLASH-xenial64/20161221.0.0/virtualbox/Vagrantfile,正如用户@prometee在本启动板讨论#1569237中所提到的。

这里是矿(第8行):

# 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 = "022999D56C03" 
    config.ssh.username = "ubuntu" 
    config.ssh.password = "fbcd1ed4fe8c83b157dc6e0f" 

    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 

FYI,用户@racb提及在同一初探兼该this bug report having been filedto ubuntu和到目前为止no [...] decision has been made yet它。

+0

所提到的'Vagrantfile'的路径已经改变了一些(可能是由于更近期的'vagrant'版本)。它现在在路径中有'/ boxes',如下所示:'〜/ .vagrant.d/boxes/ubuntu-VAGRANTSLASH-xenial64/20171028.0.0/virtualbox/Vagrantfile'。 – Ville

4

新的ubuntu/xenial64图像未附带默认用户名和密码。但是你可以使用在你的流浪文件夹中生成的ssh-key。

比方说,你Vagrantfile是/vagrant/vm01/Vagrantfile下,SSH密钥将是/vagrant/vm01/.vagrant/machines/..../private_key

您可以使用此private_key登录到您的无业游民VM。如果访客机器询问密钥的密码,只需点击ENTER(指定空白密码)。举例来说,在我的Mac:

ssh -i /vagrant/vm01/.vagrant/..../private_key <your vm user>@<your vm ip>:<your vm port> 

如果你仍想登录使用的用户名和密码,在使用PRIVATE_KEY登录后,你可以添加你自己的用户供以后登录:

# create a user for log in 
sudo useradd yourusername 

# specify a password 
sudo passwd yourusername 
# then type your password when prompted 

# add the user to sudo group 
sudo adduser yourusername sudo  

# create a home folder for your user 
sudo mkdir /home/yourusername 

# add a shell command for your user (normally /bin/bash) 
sudo vim /etc/passwd 
# find yourusername line, and add /bin/bash to the end. 
# the end result would look like this: 
yourusername:x:1020:1021::/home/yourusername:/bin/bash 

现在你可以使用新的用户名和密码了。

0

,如果这能帮助:

我的(在我的案件的Ubuntu/xenial)创建一个正常的虚拟机,然后复制与vagrant ssh-config发现识别文件,并使用该文件config.sshprivate_key_path解决了定制包装的问题,再加上还将config.ssh.username设置为ubuntu。 (另请参阅https://github.com/hashicorp/vagrant/issues/5186#issuecomment-355012068