0

好吧,我正在使用 Vagrant 对虚拟机进行一些测试,但是现在当我尝试通过终端连接 throw ssh 时,我在更改机器的默认密码“vagrant”时遇到了问题。

这是流浪文件:

Vagrant.configure(2) do |config|
  config.vm.box = "192.168.0.21"
  config.ssh.username = "vagrant"
  config.ssh.password = '123'
  config.ssh.insert_key = true
  config.vm.network "public_network", bridge: "wlan0", ip: "192.168.0.21" 
  config.vm.provider "virtualbox" do |v|
    v.name = "192.168.0.21"
    v.cpus = 1
    v.memory = 512
  end
end

您意识到我将密码(config.ssh.password)更改为“123”,但是当我重新启动机器(vagrant halt --> and vagrant up)时,会发生这种情况:

Bringing machine 'default' up with 'virtualbox' provider...
==> 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: bridged
==> 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: root
    default: SSH auth method: password
    default: Warning: Remote connection disconnect. Retrying...
    default: Warning: Remote connection disconnect. Retrying...
Text will be echoed in the clear. Please install the HighLine or Termios libraries to suppress echoed text.
root@127.0.0.1's password:

我不知道该怎么办...感谢您的帮助,谢谢!

4

1 回答 1

0

该配置不会更改机器的密码。它只是更改了 Vagrant 使用的密码,以通过 SSH 与机器进行身份验证。在文档上查看更多信息。

如果要更改机器上的用户密码,请使用默认密码初始化机器,一旦连接,您可以通过 SSH 身份验证的命令行(或 GUI,如果在 vagrant 文件上配置)更改它。

于 2016-05-29T21:44:07.283 回答