Windows上的Vagrant ssh身份验证失败

时间:2015-08-21 06:35:05

标签: windows ssh vagrant virtualbox

我正在尝试在Windows VM Ware上运行Linux Ubuntu 32位盒。我正在学习UDACITY课程,他们告诉我安装这些软件。我不太了解如何运行这些软件。我试图在Stack上找到答案,但这些都是在不同的操作系统而不是Windows上。我通过启用GUI尝试了一些编辑,我还在Vagrantfile中添加了Vagrant配置。

遇到ssh身份验证问题:

错误:

e2sn7cy@EMR-HZDEV08-003 /C/Users/e2sn7cy/fullstack/vagrant (master)
$ vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Checking if box 'ubuntu/trusty32' 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: Forwarding ports...
    default: 8000 => 1234 (adapter 1)
    default: 8080 => 8080 (adapter 1)
    default: 5000 => 4321 (adapter 1)
    default: 22 => 2222 (adapter 1)
==> 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 timeout. Retrying...
    default: Warning: Connection timeout. Retrying...
    default: Warning: Connection timeout. Retrying...
    default: Warning: Connection timeout. Retrying...
    default: Warning: Connection timeout. Retrying...
Timed out while waiting for the machine to boot. This means that
Vagrant was unable to communicate with the guest machine within
the configured ("config.vm.boot_timeout" value) time period.

If you look above, you should be able to see the error(s) that
Vagrant had when attempting to connect to the machine. These errors
are usually good hints as to what may be wrong.

If you're using a custom box, make sure that networking is properly
working and you're able to connect to the machine. It is a common
problem that networking isn't setup properly in these boxes.
Verify that authentication configurations are also setup properly,
as well.

If the box appears to be booting properly, you may want to increase
the timeout ("config.vm.boot_timeout") value.

我的Vagrantfile

# -*- mode: ruby -*-
# vi: set ft=ruby :

VAGRANTFILE_API_VERSION = "2"

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
  config.vm.provider :virtualbox do |vb|
  vb.gui = true
end

Vagrant.configure("2") do |config|
  config.ssh.private_key_path = "~/.ssh/id_rsa"
  config.ssh.forward_agent = true
end  
  config.vm.provision "shell", path: "pg_config.sh"
  # config.vm.box = "hashicorp/precise32"
  config.vm.box = "ubuntu/trusty32"
  config.vm.network "forwarded_port", guest: 8000, host: 1234
  config.vm.network "forwarded_port", guest: 8080, host: 8080
  config.vm.network "forwarded_port", guest: 5000, host: 4321

end

我的pg_config.sh

apt-get -qqy update
apt-get -qqy install postgresql python-psycopg2
apt-get -qqy install python-flask python-sqlalchemy
apt-get -qqy install python-pip
pip install bleach
pip install oauth2client
pip install requests
pip install httplib2
su postgres -c 'createuser -dRS vagrant'
su vagrant -c 'createdb'
su vagrant -c 'createdb forum'
su vagrant -c 'psql forum -f /vagrant/forum/forum.sql'

vagrantTip="[35m[1mThe shared directory is located at /vagrant\nTo access your shared files: cd /vagrant(B[m"
echo -e $vagrantTip > /etc/motd

2 个答案:

答案 0 :(得分:0)

您可以打开gui模式以查看虚拟机中发生的情况。

  • 不要更改默认配置,下载新框并使用默认配置

  • 如果你想使用python开发环境,你可以下载一个包含所有python环境的盒子

答案 1 :(得分:0)

尝试将config.vm.boot_timeout设置为更高的值,默认值为300.如下所示:

config.vm.box = "ubuntu/trusty32"
config.vm.boot_timeout = 600