【问题标题】:Laravel Homestead SSH remote sharing issueLaravel Homestead SSH 远程共享问题
【发布时间】:2017-10-01 17:04:08
【问题描述】:

我第一次测试 Vagrant 中的共享选项,我在 Windows 7 Ultimate SP1 32-bit 主机上的新 Laravel Homestead VM 配置的 Virtualbox 提供程序上进行测试。
我使用 MINGW32 作为 shell,并禁用了 Windows 防火墙(域、本地和公共),以确保这不会影响我的操作。 Vagrant 无法自动找到 HTTP 端口,所以我指定了它。
如果我运行以下命令一切顺利:

MINGW32 ~/Vagrant/Homestead ((v6.2.2))
$ vagrant share --http 8000
Vagrant Share now defaults to using the `ngrok` driver.
The `classic` driver has been deprecated.

For more information about the `ngrok` driver, please
refer to the documentation:

  https://www.vagrantup.com/docs/share/
==> homestead-7: Detecting network information for machine...
    homestead-7: Local machine address: 127.0.0.1
    homestead-7:
    homestead-7: Note: With the local address (127.0.0.1), Vagrant Share can only
    homestead-7: share any ports you have forwarded. Assign an IP or address to your
    homestead-7: machine to expose all TCP ports. Consult the documentation
    homestead-7: for your provider ('virtualbox') for more information.
    homestead-7:
    homestead-7: Local HTTP port: 8000
    homestead-7: Local HTTPS port: disabled
    homestead-7: Port: 2222
    homestead-7: Port: 27017
    homestead-7: Port: 33060
    homestead-7: Port: 44300
    homestead-7: Port: 54320
    homestead-7: Port: 8000
    homestead-7: Port: 8025
==> homestead-7: Creating Vagrant Share session...
==> homestead-7: HTTP URL: http://3bbh648b.ngrok.io
==> homestead-7:

但是以下命令失败:

MINGW32 ~/Vagrant/Homestead ((v6.2.2))
$ vagrant share --http 8000 --ssh
Vagrant Share now defaults to using the `ngrok` driver.
The `classic` driver has been deprecated.

For more information about the `ngrok` driver, please
refer to the documentation:

  https://www.vagrantup.com/docs/share/
==> homestead-7: Detecting network information for machine...
    homestead-7: Local machine address: 127.0.0.1
    homestead-7:
    homestead-7: Note: With the local address (127.0.0.1), Vagrant Share can only
    homestead-7: share any ports you have forwarded. Assign an IP or address to your
    homestead-7: machine to expose all TCP ports. Consult the documentation
    homestead-7: for your provider ('virtualbox') for more information.
    homestead-7:
==> homestead-7: Generating new SSH key...
    homestead-7: Please enter a password to encrypt the key:
Error! Your console doesn't support hiding input. We'll ask for
input again below, but we WILL NOT be able to hide input. If this
is a problem for you, ctrl-C to exit and fix your stdin.
     homestead-7: Please enter a password to encrypt the key: test
    homestead-7: Repeat the password to confirm:
Error! Your console doesn't support hiding input. We'll ask for
input again below, but we WILL NOT be able to hide input. If this
is a problem for you, ctrl-C to exit and fix your stdin.
     homestead-7: Repeat the password to confirm: test
    homestead-7: Inserting generated SSH key into machine...
    homestead-7: Local HTTP port: 8000
    homestead-7: Local HTTPS port: disabled
    homestead-7: SSH Port: 2222
    homestead-7: Port: 2222
    homestead-7: Port: 27017
    homestead-7: Port: 33060
    homestead-7: Port: 44300
    homestead-7: Port: 54320
    homestead-7: Port: 8000
    homestead-7: Port: 8025
==> homestead-7: Creating Vagrant Share session...
C:/Program Files/HashiCorp/Vagrant/embedded/mingw32/lib/ruby/2.3.0/socket.rb:61:in `connect_internal': A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. - user specified timeout (Errno::ETIMEDOUT)
        from C:/Program Files/HashiCorp/Vagrant/embedded/mingw32/lib/ruby/2.3.0/socket.rb:139:in `connect'
        from C:/Program Files/HashiCorp/Vagrant/embedded/mingw32/lib/ruby/2.3.0/socket.rb:636:in `block in tcp'
        from C:/Program Files/HashiCorp/Vagrant/embedded/mingw32/lib/ruby/2.3.0/socket.rb:231:in `each'
        from C:/Program Files/HashiCorp/Vagrant/embedded/mingw32/lib/ruby/2.3.0/socket.rb:231:in `foreach'
        from C:/Program Files/HashiCorp/Vagrant/embedded/mingw32/lib/ruby/2.3.0/socket.rb:626:in `tcp'
        from C:/Program Files/HashiCorp/Vagrant/embedded/gems/gems/vagrant-share-1.1.9/lib/vagrant-share/activate.rb:304:in `acquire_port'
        from C:/Program Files/HashiCorp/Vagrant/embedded/gems/gems/vagrant-share-1.1.9/lib/vagrant-share/activate.rb:312:in `acquire_port'
        from C:/Program Files/HashiCorp/Vagrant/embedded/gems/gems/vagrant-share-1.1.9/lib/vagrant-share/activate.rb:2360:in `block in start_share'
        from C:/Program Files/HashiCorp/Vagrant/embedded/gems/gems/vagrant-2.0.0/lib/vagrant/plugin/v2/command.rb:235:in `block in with_target_vms'
        from C:/Program Files/HashiCorp/Vagrant/embedded/gems/gems/vagrant-2.0.0/lib/vagrant/plugin/v2/command.rb:229:in `each'
        from C:/Program Files/HashiCorp/Vagrant/embedded/gems/gems/vagrant-2.0.0/lib/vagrant/plugin/v2/command.rb:229:in `with_target_vms'
        from C:/Program Files/HashiCorp/Vagrant/embedded/gems/gems/vagrant-share-1.1.9/lib/vagrant-share/activate.rb:2273:in `start_share'
        from C:/Program Files/HashiCorp/Vagrant/embedded/gems/gems/vagrant-share-1.1.9/lib/vagrant-share/activate.rb:2967:in `execute'
        from C:/Program Files/HashiCorp/Vagrant/embedded/gems/gems/vagrant-2.0.0/lib/vagrant/cli.rb:42:in `execute'
        from C:/Program Files/HashiCorp/Vagrant/embedded/gems/gems/vagrant-2.0.0/lib/vagrant/environment.rb:308:in `cli'
        from C:/Program Files/HashiCorp/Vagrant/embedded/gems/gems/vagrant-2.0.0/bin/vagrant:138:in `<main>'

我的Homestead.yml 文件是:

---
ip: "192.168.10.10"
memory: 2048
cpus: 1
provider: virtualbox

authorize: ~/.ssh/id_rsa.pub

keys:
    - ~/.ssh/id_rsa

folders:
    - map: ~/Documents/web/laravel
      to: /home/vagrant/Code

sites:
    - map: homestead.app
      to: /home/vagrant/Code/blog/public

databases:
    - homestead

# blackfire:
#     - id: foo
#       token: bar
#       client-id: foo
#       client-token: bar

# ports:
#     - send: 50000
#       to: 5000
#     - send: 7777
#       to: 777
#       protocol: udp

我可以 ping 192.168.10.10
我正在使用 Vagrant version 2.0.0 和 Virtualbox version 5.1.28 r117968 (Qt5.6.2)。 我试图转到文件C:/Program Files/HashiCorp/Vagrant/embedded/mingw32/lib/ruby/2.3.0/socket.rb 的第61 行,值local_addrinfo 的输出为空。我也尝试增加变量timeout 的值,但我没有运气。
你能帮我解决这个问题吗?我不确定它是否依赖于 Windows、MINGW32、Vagrant、Virtualbox 或 Laravel Homestead。

【问题讨论】:

    标签: windows laravel vagrant virtualbox homestead


    【解决方案1】:

    编辑 - Windows 上当前版本的vagrant share 似乎存在错误。 Vagrant 在尝试扫描打开的端口以绑定共享时抛出问题中的错误:在测试每个端口时,Vagrant 尝试打开套接字连接,并且由于没有任何东西在可用端口上侦听,Ruby 尽职尽责地抛出有问题的错误。

    解决方法 - 我们可以手动调用 ngrok,这是 Vagrant 用来配置共享的工具:

    1. https://ngrok.com/signup 创建一个帐户
    2. 复制授权令牌
    3. 安装令牌:ngrok authtoken &lt;your-token&gt;
    4. 开始共享:ngrok tcp 22222222 是您的 VM 的转发 SSH 端口)
    5. https://dashboard.ngrok.com/status找到隧道URL
    6. 使用 SSH 连接:ssh -p &lt;ngrok-port&gt; vagrant@&lt;ngrok-hostname&gt;

    为了说明,如果隧道 URL 看起来像 tcp://0.tcp.ngrok.io:55555,我们将使用以下 SSH 命令:

    ssh -p 55555 vagrant@0.tcp.ngrok.io
    

    【讨论】:

    • 感谢您的回答。我注意到,但是我的 Homestead.yml 文件内容看起来是正确的,并且我已经能够 ping 192.168.10.10
    • @itwebdeveloper 看起来你在 Vagrant 中发现了一个错误。请参阅我的更新答案。稍后我会打开一个错误报告。
    • @itwebdeveloper 这是门票:github.com/hashicorp/vagrant/issues/9036
    • 感谢您的回答以及使用 Vagrant 打开 bug 票证。我测试了您的解决方案,但是当我能够使用 SSH 连接时它仍然有效(我在 MINGW32Windows 10 Pro 64-bitPuTTY 上尝试了 SSH)SSHFS Manager (4every1 edition - v. 1.5.12.8) 在尝试安装磁盘时显示以下错误相同的参数:Homestead could not connect: An established connection was aborted by the server.。您是否知道使用 SSHFS 管理器与ngrok 的连接有任何限制?
    • @itwebdeveloper 我不时在 Linux 上通过 ngrok 使用 SSHFS,没有任何问题,但我没有在 Windows 上尝试过 SSHFS 管理器。检查 VM 内的 sshd 日志。听起来密钥交换有问题。
    猜你喜欢
    • 2017-08-05
    • 1970-01-01
    • 1970-01-01
    • 2016-03-31
    • 2017-04-25
    • 1970-01-01
    • 2017-02-17
    • 2016-12-16
    • 2016-05-21
    相关资源
    最近更新 更多