ThinkChat🤖让你学习和工作更高效,注册即送10W Token,即刻开启你的AI之旅 广告
默认的box不允许root账户登录,用默认的vagrant账户登录,方式有`private_key`和`password`两种形式 [TOC] ## 1.private_key 在之前章节正确安装完centos7后,vagrant up过程中就会在Vagrantfile同级目录生成文件夹`.vagrant`,并在centos7\.vagrant\machines\default\virtualbox下生成`private_key`文件,用xshell连接时,配置连接属性,如下步骤 ![](https://img.kancloud.cn/a1/5b/a15bac922be106ba777d7466422f4d1c_671x677.png) ![](https://img.kancloud.cn/9e/30/9e304bae2c4aad7e6589674f76ff121d_671x677.png) ![](https://img.kancloud.cn/57/9b/579b4303d9f4ab7547dd2827a769ad46_496x412.png) ![](https://img.kancloud.cn/ee/e2/eee2aaa5963c70c5f5772bc76689cfd3_960x540.png) ![](https://img.kancloud.cn/6a/9d/6a9d67d9442d3070edef69bb3d3ceab4_496x412.png) ![](https://img.kancloud.cn/a4/2c/a42cfda28cf4a74ebc3a00103ea25d37_671x677.png) ![](https://img.kancloud.cn/77/8f/778f097cf87f80a6761fcf5bfcd31307_1000x773.png) 最后双击会话连接centos7Box,已成功,如最后一张图       ## 2.password 直接用默认root账户:root/vagrant 在虚拟机上直接登录 在虚拟机的ssh配置里,vim /etc/ssh/ssd_config设置 PermitRootLogin yes # 允许root账户登录 PasswordAuthentication yes # 允许密码模式登录 ![](https://img.kancloud.cn/c5/6e/c56e1b4a30c7f1bea626f7fe5db566e4_976x559.png) 双击虚拟机,会出现登录界面,【如果不出现,按下回车】。使用默认的账户root vagrant登录,使用vagrant vagrant登录则所有的命令需要在前面加sudo,所以建议root登录,`vim /etc/ssh/ssd_config` ![](https://img.kancloud.cn/7b/fb/7bfbde67d707dbc0e3ef72a5f8141b04_816x684.png) 默认没有安装vim,所以先`yum install vim`,再执行一次如果所示命令`vim /etc/ssh/ssd_config`,进入配置页面。找到以上两个配置,设置为yes,保存退出vim,`:wq`,重启sshd服务 ![](https://img.kancloud.cn/d1/d0/d1d04e9b84972185467d99da4e019651_816x684.png) ![](https://img.kancloud.cn/f6/d1/f6d16e2dcdcbc56f31a1517a9e65976c_671x677.png) ![](https://img.kancloud.cn/c4/c3/c4c392f844c8f0ef77704c65dfc2a576_1000x773.png)