vagrant - 我无法连接到 Vagrant 处理的虚拟机 : `ssh` executable not found in any directories in the %PATH%,,但我有它

标签 vagrant virtual-machine apache-storm vagrant-windows

我是 Vagrant 的新手,我遇到了以下问题。我使用的是 Windows 8.1。

我做了以下操作:

  1. 首先,我通过以下语句将其从 github 下载到我的主机的文件夹中:

    git 克隆 https://github.com/Udacity/ud381

  2. 然后我执行了:

    Vagrant 起来

下载了包含 guest 虚拟机的 Vagrant Box

现在当我执行 vagrant up 命令时,我收到此消息:

C:\Users\Andrea\Documents\workspaces\Real-Time\ud381>vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Checking if box 'udacity/ud381' is up to date...
==> default: There was a problem while downloading the metadata for your box
==> default: to check for updates. This is not an error, since it is usually due

==> default: to temporary network problems. This is just a warning. The problem
==> default: encountered was:
==> default:
==> default: Failed connect to atlas.hashicorp.com:443; No error
==> default:
==> default: If you want to check for box updates, verify your network connectio
n
==> default: is valid and try again.
==> 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: 5000 => 5000 (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: Remote connection disconnect. Retrying...
==> default: Machine booted and ready!
==> default: Checking for guest additions in VM...
==> default: Mounting shared folders...
    default: /vagrant => C:/Users/Andrea/Documents/workspaces/Real-Time/ud381
==> default: Machine already provisioned. Run `vagrant provision` or use the `--
provision`
==> default: flag to force provisioning. Provisioners marked to run always will
still run.

我认为这是正确的,但我对此并不绝对确定,因为我似乎有一些警告消息,但它说:默认:机器启动并准备就绪!所以我认为它是好的(可以吗?)

然后我尝试通过 SSH 执行 vagrant ssh 语句来连接到它,但收到此错误消息:

C:\Users\Andrea\Documents\workspaces\Real-Time\ud381>vagrant ssh
`ssh` executable not found in any directories in the %PATH% variable. Is an
SSH client installed? Try installing Cygwin, MinGW or Git, all of which
contain an SSH client. Or use your favorite SSH client with the following
authentication information shown below:

Host: 127.0.0.1
Port: 2222
Username: vagrant
Private key: C:/Users/Andrea/Documents/workspaces/Real-Time/ud381/.vagrant/machi
nes/default/virtualbox/private_key

在 Google 上搜索,我发现要使用此语句,我需要将 git 路径放入 PATH 环境变量中。我检查并设置了它,事实上在 PATH 变量中我有这两个值:

C:\HashiCorp\Vagrant\bin;C:\Program Files\Git\bin

第一个是 vagrant 路径,第二个是 Git 路径。

所以这不是问题。在线搜索我还发现了这个 StacOverflow 讨论:

`ssh` executable not found in any directories in the %PATH%

针对此类问题发送到此链接:https://gist.github.com/haf/2843680

在此链接中,它展示了如何将ssh.rb文件修改到此文件夹C:\vagrant\vagrant\embedded\lib\ruby\gems\1.9.1\gems\vagrant-1.0.3\lib\vagrant\ssh.rb

问题是我没有这个文件夹,而是这样的:

C:\HashiCorp\Vagrant\embedded\lib\ruby\gems\2.0.0\gems\

并且此文件夹不包含 *vagrant-1.0.3\lib\vagrant* 子文件夹(包含 ssh.rb 文件),但包含 3 个目录分别命名为 rake-0.9.6rdoc-4.0.0test-unit-2.0.0.0,不包含 >ssh.rb 文件。

搜索此文件,我在这些文件夹中发现了 2 个不同的版本:

C:\HashiCorp\Vagrant\embedded\gems\gems\vagrant-1.7.4\plugins\kernel_v1\config

C:\HashiCorp\Vagrant\embedded\gems\gems\vagrant-1.7.4\plugins\kernel_v2\config

我认为也许与教程的差异可能取决于它引用了一个非常旧的 Vagrant 版本(已有 4 年历史),并且我已经安装了 1.7.4 版本 Vagrant 。

那么如何通过 SSH 连接到 Vagrant 处理的虚拟机?

最佳答案

错误信息

C:\Users\Andrea\Documents\workspaces\Real-Time\ud381>vagrant ssh `ssh`
executable not found in any directories in the %PATH% variable. Is an 
SSH client installed?

指出您当前使用的 cli(当您在 Windows 下工作时可能是 cmd 或 powershell)找不到已安装的 ssh 客户端。这意味着您的 cli 无法找到可以通过 ssh 连接到另一台服务器(在本例中为 vagrantbox)的程序。
这是一个非常常见的场景,因为 Windows 没有附带开箱即用的 ssh 客户端(与 ubuntu 或 osx 不同)。

据我所知,没有任何 ssh 程序/命令可以轻松安装并放入 PATH 中,以便它可以与 cmd 一起使用。

在这种情况下,您可能想要做的是安装具有这些功能的不同 cli。这里有几个选项,它们也在错误消息中说明:

Try installing Cygwin, MinGW or Git, all of which
contain an SSH client

我建议您使用 Git Bash,自从您使用 git 以来,您可能已经在系统上安装了它。

因此,要执行vagrant ssh,您的第一步将是通过执行程序本身来启动 Git Bash(它随 git 一起提供,在我的系统上可以在以下位置找到:C:\Program Files\Git\git-bash.exe)或右键单击 Windows 资源管理器中的目录列表并选择 Git Bash here (这仅在您选中某个框时才有效Git 安装后)。
它将打开一个新的 cli,它可以使用类似 linux 的命令。 您现在应该能够进入 vagrant 目录并执行 vagrant ssh

您在问题中链接到的解决方案似乎不再有效,因为与 git 通信的 ssh 客户端的路径似乎已更改。

关于vagrant - 我无法连接到 Vagrant 处理的虚拟机 : `ssh` executable not found in any directories in the %PATH%,,但我有它,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33412239/

相关文章:

macos - 无法从 OSX 主机上的 Ubuntu 客户机的串行端口读取数据

distributed-computing - Storm 如何管理集群模式下的共享数据?

java - 在多个数据库编写器 bolt /数据库查询路由器之间平均分割 Storm 流?

raspberry-pi - 是否有模拟 Raspberry Pi 的 Vagrant 盒子?

chef-infra - Vagrant 问题

具有经典部署、公共(public) IP 地址的 Azure 经典 CLI

java - Storm DRPC 中的更新与请求-回复

laravel - Vagrant/Homestead ssh 身份文件无法访问 : no such file or directory

vagrant - 如何使用 Vagrant、Puppet 和 Hiera 配置时区?

database - 比 mysqldump 更快的备份和恢复 MySQL 数据库的方法是什么? (快于4小时)