关于如何在Vagrant下使用root用户登录的问题
来源:6-4 水平扩展和负载均衡
Kokutou
2018-03-04
参见如下链接:
附上我的Vagrantfile文件内容以便参考:
Vagrant.require_version ">= 1.6.0"
boxes = [
{
:name => "CentOS7",
:eth1 => "192.168.205.10",
:mem => "1024",
:cpu => "1"
}
]
Vagrant.configure(2) do |config|
# additions version when booting this machine
config.vbguest.auto_update = false
# do NOT download the iso file from a webserver
config.vbguest.no_remote = true
config.vm.box = "centos7"
config.ssh.username = 'root'
config.ssh.password = 'vagrant'
config.ssh.insert_key = 'true'
boxes.each do |opts|
config.vm.define opts[:name] do |config|
config.vm.hostname = opts[:name]
config.vm.provider :parallels do |prl|
prl.memory = opts[:mem]
prl.cpus = opts[:cpu]
end
config.vm.network :private_network, ip: opts[:eth1]
end
end
config.vm.synced_folder "./labs", "/home/vagrant/labs",:nfs => true
end主要就是这三行代码
config.ssh.username = 'root' config.ssh.password = 'vagrant' config.ssh.insert_key = 'true'
Vagrantfile里面的内容不要照抄,因为我用的虚拟机不是VirtualBox。
另外,下面这行
config.vm.synced_folder "./labs", "/home/vagrant/labs",:nfs => true
:nfs => true是用来开启NFS文件系统提升Vagrant共享目录性能的。
写回答
1回答
-
您好,很棒。默认的用户名密码一般是vagrant/vagrant,这个用户也是具有sudo权限的。
012018-03-04
相似问题