新的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
现在你可以使用新的用户名和密码了。
值得一提的是,这打破了用户的流浪标准/将两者默认为“流浪”。 https://www.vagrantup.com/docs/boxes/base.html – Ryre