我正在尝试设置 Vagrant 和 Hyper-V,几乎已经完成,但文件夹共享失败,因为我拒绝使用 SMB,而是想使用vagrant-sshfs。众所周知,在 Windows 系统中需要有一个sftp-server
通常由 OpenSSH 提供的,因此我遵循了这在 Windows 10 中安装 OpenSSH 的说明。
我的样子如下Vagrantfile
:
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
config.vm.box = "centos/7"
config.vm.network :forwarded_port, host: 8080, guest: 80
config.vm.network "private_network", ip: "192.168.50.4"
config.vm.synced_folder "../../applications", "/var/www", type: "sshfs", , sshfs_opts_append: "-o cache=no"
config.vm.provider :hyperv do |vb|
vb.memory = "2048"
vb.vmname = "centos7"
end
end
当我运行该命令时,vagrant up
我得到以下信息:
λ vagrant up
Bringing machine 'default' up with 'hyperv' provider...
==> default: Verifying Hyper-V is enabled...
==> default: Verifying Hyper-V is accessible...
default: Configuring the VM...
==> default: Starting the machine...
==> default: Waiting for the machine to report its IP address...
default: Timeout: 120 seconds
default: IP: 192.168.0.103
==> default: Waiting for machine to boot. This may take a few minutes...
default: SSH address: 192.168.0.103:22
default: SSH username: vagrant
default: SSH auth method: private key
==> default: Machine booted and ready!
==> default: Mounting SSHFS shared folder...
==> default: Mounting folder via SSHFS: E:/Development/applications => /var/www/html
==> default: Checking Mount..
==> default: Checking Mount..
==> default: Checking Mount..
==> default: Checking Mount..
==> default: Checking Mount..
==> default: Checking Mount..
==> default: Checking Mount..
Mounting SSHFS shared folder via slave SSHFS mount failed. Please
look at the below STDERR output from the processes that were run.
SSH command:
Warning: Permanently added '192.168.0.103' (ECDSA) to the list of known hosts.
fuse: mountpoint is not empty
fuse: if you are sure this is safe, use the 'nonempty' mount option
SFTP command:
有人能帮我正确设置吗?为什么我在这里找不到?
答案1
虽然我现在无法在 Win10 上检查它,但我在 MacOS 主机上使用 VirtualBox 时遇到了与 Ubuntu 18.4 类似的问题。错误消息似乎与此有关SSHFS
。
添加'非空' 选项对我有用sshfs_opts_append
:
config.vm.synced_folder "../../applications", "/var/www", type: "sshfs", sshfs_opts_append: "-o nonempty -o cache=no"
尝试您的配置时似乎有一个多余的逗号 - 我必须将其删除。