一 安裝好 VirtualBox+Vagrant(此處省略)
遇到問題:
Vagrant2.2.5無法使用VirtualBox6.1.8解決方案
https://blog.csdn.net/weixin_43838639/article/details/106210459
二 初始化
1 打開cmd視窗 執行
vagrant init centos7 https://mirrors.ustc.edu.cn/centos-cloud/centos/7/vagrant/x86_64/images/CentOS-7.box
vagrant up

2 編輯Vagrantfile修改CentOs 7ip
直接加上
config.vm.network "private_network", ip: "192.168.56.12"
3 重新開機虛拟機
vagrant reload
4 進入虛拟機
vagrant ssh
5 檢視此時linux 的ip
ifconfig
報錯 -bash:ifconfig: command not found
執行
sudo yum install net-tools
一直選擇 y 完事
再次執行 ifconfig
确實 是之前配的ip
三 xhell 進行連接配接
1 選擇 Public key
VirtualBox+Vagrant 快速初始化 CentOs 7
2 導入使用者秘鑰
路徑: 你的檔案夾\.vagrant\machines\default\virtualbox
直接點選連接配接後
輸入使用者名/密碼
vagrant/vagrant
3 修改root 使用者密碼
一 切換root使用者
sudo -i
二 初始化密碼
passwd
三 修改 /etc/ssh/sshd_config
修改 ssd_config 裡 PermitRootLogin屬性 改為yes ,去掉注釋
PasswordAuthentication 改為yes 并且去掉 注釋 #
找不到直接/PasswordAuthentication 搜
四 儲存退出 重新開機服務
systemctl restart sshd
下次登入 就可以用root 使用者登啦 !!!
打完收工