首先下载 vagrant 和 VirtualBox
在新建一个home目录,初始化并下载box包
vagrant init centos7 https://mirrors.ustc.edu.cn/centos-cloud/centos/7/vagrant/x86_64/images/CentOS-7.box
vagrant up
vagrant ssh(vagrant ssh登录,密码默认是vagrant)
在命令行下,编辑文件并重启
vi /etc/ssh/sshd_config
# PermitRootLogin prohibit-password
PermitRootLogin yes # 允许 root 身份登录
# PasswordAuthentication on
PasswordAuthentication yes # 可以使用密码登录
sudo systemctl restart sshd
在home目录下
修改Vagrantfile文件,开启
私有网络,配置host;
配置登陆账号密码;
取消ssh的key
config.vm.network "private_network", ip: "192.168.33.10"
config.ssh.password = "123123"
config.ssh.username = "root"
config.ssh.insert_key = false
重新登录
vagrant ssh
其他命令参考
vagrant up (开机)
vagrant halt (关机)
vagrant reload (重新加载配置)
https://www.cnblogs.com/xingxia/p/vagrant_base.html
参考
https://www.vagrantup.com/docs/vagrantfile/ssh_settings.html#config-ssh-password
https://www.cnblogs.com/hafiz/p/9175484.html
http://wxnacy.com/2019/07/18/vagrant-root-login/
https://blog.csdn.net/u011781521/article/details/80275212