putty 连接到 VM CentOS 7 (Vagrant / Virtualbox) 时出现问题

putty 连接到 VM CentOS 7 (Vagrant / Virtualbox) 时出现问题

我已经使用 Vagrant (2.2.3) 和 Virtual Box (5.2.24) 在 Windows 10 上以这种方式创建了一个 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 启动,但当我尝试使用 IP 地址 (192.168.33.10) 通过 Putty(端口 22 上的 SSH)连接时,出现以下错误

在此输入图像描述

我哪里做错了?

答案1

我已经解决了!

我已编辑/etc/ssh/sshd_config文件并将其sudo vi /etc/ssh/sshd_config更改#PasswordAuthentication yesPasswordAuthentication yes(取消注释该行...)。

然后我使用命令重新启动了 sshd 服务 sudo systemctl restart sshd ,现在当我从 Putty 连接我的 VM CentOS 7 时一切正常。

相关内容