我已经在 Windows 10 上以这种方式使用 Vagrant(2.2.3)和 Virtual Box(5.2.24)创建了一个 VM CentOS7(按照这些说明...https://blog.centos.org/2019/02/updated-centos-vagrant-images-available-v1901-01/)
vagrant init centos/7
vagrant up
一切正常
然后我安装了 Guest Addition (rif.https://github.com/dotless-de/vagrant-vbguest), 这样
vagrant plugin install vagrant-vbguest
我的最后一个Vagrantfile
是
Vagrant.configure("2") do |config|
config.vm.box = "centos/7"
config.vm.network "private_network", ip: "192.168.33.10"
config.vm.synced_folder ".", "/vagrant", type: "virtualbox"
config.vm.provider "virtualbox" do |vb|
vb.memory = "4096"
vb.name = "Test"
end
end
执行vagrant up
工作正常
$ vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Checking if box 'centos/7' version '1901.01' is up to date...
==> default: Clearing any previously set forwarded ports...
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
default: Adapter 1: nat
default: Adapter 2: hostonly
==> default: Forwarding ports...
default: 22 (guest) => 2222 (host) (adapter 1)
==> default: Running 'pre-boot' VM customizations...
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
default: SSH address: 127.0.0.1:2222
default: SSH username: vagrant
default: SSH auth method: private key
default: Warning: Connection reset. Retrying...
default: Warning: Connection aborted. Retrying...
default: Warning: Remote connection disconnect. Retrying...
==> default: Machine booted and ready!
[default] GuestAdditions 5.2.24 running --- OK.
==> default: Checking for guest additions in VM...
==> default: Configuring and enabling network interfaces...
==> default: Mounting shared folders...
default: /vagrant => D:/Cesare/Personale/VagrantCentOS7/TestNew
==> default: Machine already provisioned. Run `vagrant provision` or use the `--provision`
==> default: flag to force provisioning. Provisioners marked to run always will still run.
VM 启动并vagrant ssh
正常工作,但当我尝试使用 IP 地址 (192.168.33.10) 通过 Putty(端口 22 上的 SSH)连接时,出现以下错误
我哪里做错了?
答案1
我的声誉不够高,无法发表评论,但我可以发表答案。
看看/var/log/消息当您通过连接时,文件vagrant ssh
。我怀疑/etc/ssh/sshd_config文件有允许Root登录设置无需密码或其他类似设置。如果您想以 root 身份使用密码连接,请将其更改为PermitRootLogin 是。