vagrant-sshfs 1.2.0 → 1.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 74c0ac801cbf4908bc4c4afa128e205764b899fd
4
- data.tar.gz: 0e842c7729c4bd1a746aa41c16506006720722a9
3
+ metadata.gz: 5dfa628705000436923d10ab6c28c81b0a0224f0
4
+ data.tar.gz: dcbd353a54a12bfbc5fe3c44673b027213d7873b
5
5
  SHA512:
6
- metadata.gz: a2727626ab76dab2502ba3671e36999dbfd38efbba0528089d43f2f80169c862ed4555c70b8dd2acaa57873123511a1e60537ae8255f1edc331df0cf43d21615
7
- data.tar.gz: abee837f9c6b2bd264204ae6990523213d3951c6dfe2a00e063a028ec4a7cd51e370c555a78805e8008a9983c4700efc003aac36f90f5daca02c6abe40333d98
6
+ metadata.gz: 93ef3f2a946e095d197cd49a9af02cbbc83970905a867f1a5092a71e13c10e313392337f373396058f391830b49fa0120b2bde0e8a442d900c168a781c8cbe2e
7
+ data.tar.gz: 74aad85b4d51019b5af792be1feebf4e99f6c59edab6d8299f723dd12bcd1ccfd288a4b205aef733f732fbd2a224c97b52af46dcd5c09e20751673e5942956b4
data/Gemfile CHANGED
@@ -6,7 +6,7 @@ group :development do
6
6
  # We depend on Vagrant for development, but we don't add it as a
7
7
  # gem dependency because we expect to be installed within the
8
8
  # Vagrant environment itself using `vagrant plugin`.
9
- gem "vagrant", :git => "https://github.com/mitchellh/vagrant.git", :ref => 'v1.8.4'
9
+ gem "vagrant", :git => "https://github.com/mitchellh/vagrant.git", :ref => 'v1.8.6'
10
10
  end
11
11
 
12
12
  group :plugins do
@@ -0,0 +1,307 @@
1
+ = vagrant-sshfs
2
+ :toc:
3
+ :toc-placement!:
4
+
5
+ This Vagrant plugin adds synced folder support for mounting
6
+ folders from the Vagrant host into the Vagrant guest via
7
+ https://github.com/libfuse/sshfs[SSHFS]. In the default mode it does
8
+ this by executing the `SSHFS` client software within the guest, which
9
+ creates an SSH connection from the Vagrant guest back to the Vagrant
10
+ host.
11
+
12
+ '''
13
+ toc::[]
14
+ '''
15
+ [[considerations]]
16
+ == Considerations
17
+
18
+ The benefits of this approach:
19
+
20
+ * Works on any host platform and hypervisor type
21
+ ** Windows, Linux, Mac OS X
22
+ ** Virtualbox, Libvirt, Hyper-V, VMWare
23
+ * Seamlessly works on remote Vagrant solutions
24
+ ** Works with vagrant aws/openstack/etc.. plugins
25
+
26
+ The drawbacks with this approach:
27
+
28
+ * Performance is worse than an implementation like NFS
29
+ * There must be `sftp-server` software on the Vagrant host
30
+
31
+ `sftp-server` is usually provided by SSH server software so it already
32
+ exists on Linux/Mac. On windows you only need to install
33
+ https://cygwin.com/cgi-bin2/package-grep.cgi?grep=openssh&arch=x86_64[openssh]
34
+ via https://cygwin.com/[cygwin] and you will get `sftp-server`.
35
+
36
+
37
+ [[history]]
38
+ == History
39
+
40
+ The inspiration for this plugin came from
41
+ https://github.com/fabiokr[Fabio Kreusch] and his
42
+ https://github.com/fabiokr/vagrant-sshfs[code] for the original
43
+ vagrant-sshfs Vagrant plugin. The goal of this plugin (as opposed to the
44
+ old implementation) is to implement SSHFS as a synced folder plugin just
45
+ like the other synced folder plugins (NFS/RSYNC/SMB/VirtualBox).
46
+
47
+ This plugin was developed mainly by copying the code from the NFS synced
48
+ folder plugin from the Vagrant core code and molding it to fit SSHFS.
49
+
50
+ [[modes-of-operation]]
51
+ == Modes of Operation
52
+
53
+ [[sharing-vagrant-host-directory-to-vagrant-guest---98-of-users]]
54
+ === Sharing Vagrant Host Directory to Vagrant Guest - 98% of users
55
+
56
+ This plugin uses SSHFS slave mounts (see
57
+ https://github.com/dustymabe/vagrant-sshfs/issues/11[link]) to mount a
58
+ directory from the Vagrant Host into the Vagrant Guest. It uses the
59
+ `sftp-server` software that exists on the host and `sshfs` running in
60
+ _slave mode_ within the guest to create a connection using the existing
61
+ authentication over SSH that vagrant sets up for you.
62
+
63
+ [[sharing-arbitrary-host-directory-to-vagrant-guest---1-of-users]]
64
+ === Sharing Arbitrary Host Directory to Vagrant Guest - 1% of users
65
+
66
+ This plugin allows you to share a folder from an arbitrary host to the
67
+ Vagrant Guest. This would allow you to do a folder mount to some other
68
+ host that may have files that you need. To do this the plugin will run
69
+ an SSHFS command from the Guest and connect to the arbitrary host that
70
+ must have an SSH daemon running. You must provide the `ssh_host` option
71
+ in the Vagrantfile to get this to work. You can use ssh key forwarding
72
+ or username/password for authentication for this.
73
+
74
+ See link:#options-specific-to-arbitrary-host-mounting[Options] and
75
+ link:#appendix-a-using-keys-and-forwarding-ssh-agent[Appendix A] for
76
+ more information.
77
+
78
+ [[sharing-vagrant-guest-directory-to-vagrant-host---1-of-users]]
79
+ === Sharing Vagrant Guest Directory to Vagrant Host - 1% of users
80
+
81
+ _NOTE:_ This option is dangerous as data will be destroyed upon
82
+ `vagrant destroy`
83
+
84
+ This plugin allows you to share a folder from a Vagrant guest into the
85
+ host. If you have workloads where there are a lot of disk intensive
86
+ operations (such as compilation) it may be ideal to have the files live
87
+ in the guest where the disk intensive operations would occur. For
88
+ discussion see https://github.com/dustymabe/vagrant-sshfs/issues/7[Issue
89
+ #7].
90
+
91
+ See link:#options-specific-to-reverse-mounting-guest-host-mount[Options]
92
+ for more information on how to enable this type of mount.
93
+
94
+ [[getting-started]]
95
+ == Getting Started
96
+
97
+ In order to use this synced folder implementation perform the following
98
+ steps:
99
+
100
+ [[install-plugin]]
101
+ === Install Plugin
102
+
103
+ In order to install the plugin simply run the following command:
104
+
105
+ ....
106
+ # vagrant plugin install vagrant-sshfs
107
+ ....
108
+
109
+ [[add-sshfs-synced-folder-in-vagrantfile]]
110
+ === Add SSHFS Synced Folder in Vagrantfile
111
+
112
+ Edit your Vagrantfile to specify a folder to mount from the host into
113
+ the guest:
114
+
115
+ ....
116
+ config.vm.synced_folder "/path/on/host", "/path/on/guest", type: "sshfs"
117
+ ....
118
+
119
+ Now you can simply `vagrant up` and your folder should be mounted in the
120
+ guest. For more options that you can add see the link:#options[Options]
121
+ section.
122
+
123
+ [[executing-the-vagrant-sshfs-command]]
124
+ == Executing the `vagrant sshfs` Command
125
+
126
+ The Vagrant SSHFS plugin also supports execution of the `vagrant sshfs`
127
+ command from the command line. Executing this command with the `--mount`
128
+ option will iterate through the Vagrant file and attempt to mount (via
129
+ SSHFS) any folders that aren't already mounted in the Vagrant guest.
130
+ Executing with the `--unmount` option will unmount any mounted folders.
131
+
132
+ ....
133
+ vagrant sshfs [--mount|--unmount] [vm-name]
134
+ ....
135
+
136
+ [[options]]
137
+ == Options
138
+
139
+ The SSHFS synced folder plugin supports a few options that can be
140
+ provided in the `Vagrantfile`. The following sections describe the
141
+ options in more detail.
142
+
143
+ [[generic-options]]
144
+ === Generic Options
145
+
146
+ The SSHFS synced folder plugin supports a few options that can be
147
+ provided in the `Vagrantfile`. They are described below:
148
+
149
+ * `disabled`
150
+ ** If set to 'true', ignore this folder and don't mount it.
151
+ * `ssh_opts_append`
152
+ ** Add some options for the ssh connection that will be established.
153
+ ** See the ssh man page for more details on possible options.
154
+ * `sshfs_opts_append`
155
+ ** Add some options for the sshfs fuse mount that will made
156
+ ** See the sshfs man page for more details on possible options.
157
+
158
+ An example snippet from a `Vagrantfile`:
159
+
160
+ ....
161
+ config.vm.synced_folder "/path/on/host", "/path/on/guest",
162
+ ssh_opts_append: "-o Compression=yes -o CompressionLevel=5",
163
+ sshfs_opts_append: "-o auto_cache -o cache_timeout=115200",
164
+ disabled: false, type: "sshfs"
165
+ ....
166
+
167
+ [[options-specific-to-arbitrary-host-mounting]]
168
+ === Options Specific to Arbitrary Host Mounting
169
+
170
+ The following options are only to be used when
171
+ link:#sharing-arbitrary-host-directory-to-vagrant-guest---1-of-users[sharing
172
+ an arbitrary host directory] with the guest. They will be ignored
173
+ otherwise:
174
+
175
+ * `ssh_host`
176
+ ** The host to connect to via SSH. If not provided this will be detected
177
+ as the Vagrant host that is running the Vagrant guest.
178
+ * `ssh_port`
179
+ ** The port to use when connecting. Defaults to port 22.
180
+ * `ssh_username`
181
+ ** The username to use when connecting. If not provided it is detected
182
+ as the current user who is interacting with Vagrant.
183
+ * `ssh_password`
184
+ ** The password to use when connecting. If not provided and the user is
185
+ not using SSH keys, then the user will be prompted for the password.
186
+ Please use SSH keys and don't use this option!
187
+ * `prompt_for_password`
188
+ ** The user can force Vagrant to interactively prompt the user for a
189
+ password by setting this to 'true'. Alternatively the user can deny
190
+ Vagrant from ever prompting for the password by setting this to 'false'.
191
+
192
+ An example snippet from a `Vagrantfile`:
193
+
194
+ ....
195
+ config.vm.synced_folder "/path/on/host", "/path/on/guest",
196
+ ssh_host: "somehost.com", ssh_username: "fedora",
197
+ ssh_opts_append: "-o Compression=yes -o CompressionLevel=5",
198
+ sshfs_opts_append: "-o auto_cache -o cache_timeout=115200",
199
+ disabled: false, type: "sshfs"
200
+ ....
201
+
202
+ [[options-specific-to-reverse-mounting-guest-host-mount]]
203
+ === Options Specific to Reverse Mounting (Guest->Host Mount)
204
+
205
+ If your host has the `sshfs` software installed then the following
206
+ options enable mounting a folder from a Vagrant Guest into the Vagrant
207
+ Host:
208
+
209
+ * `reverse`
210
+ ** This can be set to 'true' to enable reverse mounting a guest folder
211
+ into the Vagrant host.
212
+
213
+ An example snippet from a `Vagrantfile` where we want to mount `/data`
214
+ on the guest into `/guest/data` on the host:
215
+
216
+ ....
217
+ config.vm.synced_folder "/guest/data", "/data", type: 'sshfs', reverse: true
218
+ ....
219
+
220
+ [[faq]]
221
+ == FAQ
222
+
223
+ Here are some answers to some frequently asked questions:
224
+
225
+ [[why-do-new-files-take-time-to-appear-inside-the-guest]]
226
+ === Why do new files take time to appear inside the guest?
227
+
228
+ Sometimes it can take time for files to appear on the other end of the
229
+ sshfs mount. An example would be I create a file on my host system and
230
+ then it doesn't show up inside the guest mount for 10 to 20 seconds.
231
+ This is because of caching that SSHFS does to improve performance.
232
+ Performance vs accuracy is always going to be a trade-off. If you'd like
233
+ to disable caching completely you can disable caching completely by
234
+ appending the `cache=no` SSHFS option to the synced folder definition in
235
+ the Vagrantfile like so:
236
+
237
+ ....
238
+ config.vm.synced_folder "/path/on/host", "/path/on/guest",
239
+ type: "sshfs", sshfs_opts_append: "-o cache=no"
240
+ ....
241
+
242
+ All caching options that are available to sshfs can be added/modified in
243
+ this same manner.
244
+
245
+ [[appendix-a-using-keys-and-forwarding-ssh-agent]]
246
+ == Appendix A: Using Keys and Forwarding SSH Agent
247
+
248
+ When
249
+ link:#sharing-arbitrary-host-directory-to-vagrant-guest---1-of-users[sharing
250
+ an arbitrary host directory] you may want a completely non-interactive
251
+ experience. You can either hard code your password in the Vagrantfile or
252
+ you can use SSH keys. A few guides for setting up ssh keys and key
253
+ forwarding are on Github:
254
+
255
+ * https://help.github.com/articles/generating-ssh-keys[Key Generation]
256
+ * https://developer.github.com/guides/using-ssh-agent-forwarding/[Key Forwarding]
257
+
258
+ The idea is that if `key1` is a key that is authorized to log in to the
259
+ Vagrant host ,meaning there is an entry for `key1` in the
260
+ `~/.ssh/authorized_keys` file, then you should be able to do the
261
+ following to have a non-interactive experience with SSH keys and agent
262
+ forwarding:
263
+
264
+ Modify the Vagrantfile to forward your SSH agent:
265
+
266
+ ....
267
+ config.ssh.forward_agent = 'true'
268
+ ....
269
+
270
+ Now set up your agent and add your key to the agent:
271
+
272
+ ....
273
+ # eval $(ssh-agent)
274
+ # ssh-add /path/to/key1
275
+ ....
276
+
277
+ And finally bring up your Vagrant guest:
278
+
279
+ ....
280
+ # vagrant up
281
+ ....
282
+
283
+ [[appendix-b-development]]
284
+ == Appendix B: Development
285
+
286
+ For local development of this plugin here is an example of how to build,
287
+ test and install this plugin on your local machine:
288
+
289
+ ....
290
+ # Install development dependencies
291
+ $ gem install bundler && bundle install
292
+
293
+ # List available Rake tasks
294
+ $ bundle exec rake -T
295
+
296
+ # Run Cucumber tests
297
+ $ bundle exec rake featuretests
298
+
299
+ # Build the gem (gets generated in the 'pkg' directory
300
+ $ bundle exec rake build
301
+
302
+ # Run Vagrant in the context of the plugin
303
+ $ bundle exec vagrant <command>
304
+
305
+ # Install built gem into global Vagrant installation (run outside of git checkout!)
306
+ $ vagrant plugin install <path to gem in pkg directory>
307
+ ....
@@ -0,0 +1,39 @@
1
+
2
+ Make sure to bump version and commit
3
+
4
+ Install git-evtag
5
+
6
+ git-evtag sign v1.2.0
7
+
8
+ -> In vim add thanks to contributors - grab info with
9
+ git log --no-merges --pretty=format:"%h - %an - %s"
10
+ and
11
+ git log --no-merges --pretty=format:"%h - %ae - %s"
12
+
13
+
14
+ -> In vim add commit log - grab with
15
+ git log --no-merges --pretty=format:"%h %s"
16
+
17
+ -> In vim add release message - see previous tag for example
18
+
19
+ close and type in password for signing
20
+
21
+ verify with git-evtag verify v1.2.0
22
+ verify with git verify-tag v1.2.0
23
+
24
+ git push
25
+ git push --tags
26
+
27
+ # Build with bundle exec rake build (inside viv VM)
28
+ bundle exec rake build
29
+
30
+ # Sign the output
31
+ gpg --armor --detach-sign pkg/vagrant-sshfs-1.2.0.gem
32
+ $ ls pkg/vagrant-sshfs-1.2.0.gem*
33
+ pkg/vagrant-sshfs-1.2.0.gem pkg/vagrant-sshfs-1.2.0.gem.asc
34
+
35
+ # Update release notes and upload files on github
36
+
37
+ # push to rubygems with:
38
+ gem push pkg/vagrant-sshfs-1.2.0.gem
39
+
@@ -176,10 +176,11 @@ module VagrantPlugins
176
176
  sshfs_cmd+= sshfs_opts + ' ' + sshfs_opts_append + ' '
177
177
 
178
178
  # The ssh command to connect to guest and then launch sshfs
179
+ # Note the backslash escapes for IdentityFile - handles spaces in key path
179
180
  ssh_opts = opts[:ssh_opts]
180
181
  ssh_opts+= ' -o User=' + machine.ssh_info[:username]
181
182
  ssh_opts+= ' -o Port=' + machine.ssh_info[:port].to_s
182
- ssh_opts+= ' -o IdentityFile=' + machine.ssh_info[:private_key_path][0]
183
+ ssh_opts+= ' -o "IdentityFile=\"' + machine.ssh_info[:private_key_path][0] + '\""'
183
184
  ssh_opts+= ' -o UserKnownHostsFile=/dev/null '
184
185
  ssh_opts+= ' -F /dev/null ' # Don't pick up options from user's config
185
186
  ssh_cmd = ssh_path + ssh_opts + ' ' + ssh_opts_append + ' ' + machine.ssh_info[:host]
@@ -75,9 +75,10 @@ module VagrantPlugins
75
75
  opts[:ssh_opts]+= ' -o ServerAliveInterval=30 ' # send keepalives
76
76
 
77
77
  # SSH connection options
78
+ # Note the backslash escapes for IdentityFile - handles spaces in key path
78
79
  ssh_opts = opts[:ssh_opts]
79
80
  ssh_opts+= ' -o Port=' + machine.ssh_info[:port].to_s
80
- ssh_opts+= ' -o IdentityFile=' + machine.ssh_info[:private_key_path][0]
81
+ ssh_opts+= ' -o "IdentityFile=\"' + machine.ssh_info[:private_key_path][0] + '\""'
81
82
  ssh_opts+= ' -o UserKnownHostsFile=/dev/null '
82
83
  ssh_opts+= ' -F /dev/null ' # Don't pick up options from user's config
83
84
 
@@ -1,5 +1,5 @@
1
1
  module VagrantPlugins
2
2
  module SyncedFolderSSHFS
3
- VERSION = "1.2.0"
3
+ VERSION = "1.2.1"
4
4
  end
5
5
  end
@@ -11,5 +11,10 @@ and then:
11
11
 
12
12
  cd /sharedfolder/code/github.com/dustymabe/vagrant-sshfs/
13
13
  gem install bundler
14
- bundle install
14
+ bundle install --with plugins # see [1]
15
15
  bundle exec rake featuretests
16
+
17
+ [1] when running with bundler 1.13.2 I had to comment out
18
+ the vagrant-sshfs line in Gemfile because it errored out
19
+ complaining about it being defined twice. Running with
20
+ 1.12.5 works fine.
@@ -13,5 +13,10 @@ and then:
13
13
 
14
14
  cd /sharedfolder/code/github.com/dustymabe/vagrant-sshfs/
15
15
  gem install bundler
16
- bundle install
16
+ bundle install --with plugins # see [1]
17
17
  bundle exec rake featuretests
18
+
19
+ [1] when running with bundler 1.13.2 I had to comment out
20
+ the vagrant-sshfs line in Gemfile because it errored out
21
+ complaining about it being defined twice. Running with
22
+ 1.12.5 works fine.
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vagrant-sshfs
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dusty Mabe
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-08-08 00:00:00.000000000 Z
11
+ date: 2016-11-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: win32-process
@@ -105,7 +105,8 @@ files:
105
105
  - ".gitignore"
106
106
  - Gemfile
107
107
  - LICENSE
108
- - README.md
108
+ - README.adoc
109
+ - RELEASE.txt
109
110
  - Rakefile
110
111
  - features/README.md
111
112
  - features/sshfs_cwd_mount.feature
data/README.md DELETED
@@ -1,271 +0,0 @@
1
- # vagrant-sshfs
2
-
3
- This is a vagrant plugin that adds synced folder support for mounting
4
- folders from the Vagrant host into the Vagrant guest via
5
- [SSHFS](https://github.com/libfuse/sshfs). In the default mode it does
6
- this by executing the `SSHFS` client software within the guest, which
7
- creates an SSH connection from the Vagrant guest back to the Vagrant host.
8
-
9
- The benefits of this approach:
10
- - Works on any host platform and hypervisor type
11
- - Windows, Linux, Mac OS X
12
- - Virtualbox, Libvirt, Hyper-V, VMWare
13
- - Seamlessly works on remote Vagrant solutions
14
- - Works with vagrant aws/openstack/etc.. plugins
15
-
16
- The drawbacks with this approach:
17
- - Performance is worse than an implementation like NFS
18
- - There must be `sftp-server` software on the Vagrant host
19
-
20
- `sftp-server` is usually provided by SSH server software so it already
21
- exists on Linux/Mac. On windows you only need to install
22
- [openssh](https://cygwin.com/cgi-bin2/package-cat.cgi?file=x86_64%2Fopenssh%2Fopenssh-7.2p1-1&grep=openssh)
23
- via [cygwin](https://cygwin.com/) and you will get `sftp-server`.
24
-
25
- ## History
26
-
27
- The inspiration for this plugin came from [Fabio Kreusch](https://github.com/fabiokr)
28
- and his [code](https://github.com/fabiokr/vagrant-sshfs) for the original
29
- vagrant-sshfs Vagrant plugin. The goal of this plugin (as opposed to
30
- the old implementation) is to implement SSHFS as a synced folder
31
- plugin just like the other synced folder plugins (NFS/RSYNC/SMB/VirtualBox).
32
-
33
- This plugin was developed mainly by copying the code from the NFS synced
34
- folder plugin from the Vagrant core code and molding it to fit SSHFS.
35
-
36
- ## Modes of Operation
37
-
38
- ### Sharing Vagrant Host Directory to Vagrant Guest - 98% of users
39
-
40
- This plugin uses SSHFS slave mounts
41
- (see [link](https://github.com/dustymabe/vagrant-sshfs/issues/11))
42
- to mount a directory from the Vagrant Host into the Vagrant Guest. It
43
- uses the `sftp-server` software that exists on the host and `sshfs`
44
- running in *slave mode* within the guest to create a connection using
45
- the existing authentication over SSH that vagrant sets up for you.
46
-
47
- ### Sharing Arbitrary Host Directory to Vagrant Guest - 1% of users
48
-
49
- This plugin allows you to share a folder from an arbitrary host to the
50
- Vagrant Guest. This would allow you to do a folder mount to some other
51
- host that may have files that you need. To do this the plugin will run
52
- an SSHFS command from the Guest and connect to the arbitrary host that
53
- must have an SSH daemon running. You must provide the `ssh_host`
54
- option in the Vagrantfile to get this to work. You can use ssh key
55
- forwarding or username/password for authentication for this.
56
-
57
- See [Options](#options-specific-to-arbitrary-host-mounting) and
58
- [Appendix A](#appendix-a-using-keys-and-forwarding-ssh-agent) for
59
- more information.
60
-
61
- ### Sharing Vagrant Guest Directory to Vagrant Host - 1% of users
62
-
63
- *NOTE:* This option is dangerous as data will be destroyed upon `vagrant destroy`
64
-
65
- This plugin allows you to share a folder from a Vagrant guest into the
66
- host. If you have workloads where there are a lot of disk intensive
67
- operations (such as compilation) it may be ideal to have the files
68
- live in the guest where the disk intensive operations would occur.
69
- For discussion see [Issue #7](https://github.com/dustymabe/vagrant-sshfs/issues/7).
70
-
71
- See [Options](#options-specific-to-reverse-mounting-guest-host-mount)
72
- for more information on how to enable this type of mount.
73
-
74
- ## Getting Started
75
-
76
- In order to use this synced folder implementation perform the
77
- following steps:
78
-
79
- ### Install Plugin
80
-
81
- In order to install the plugin simply run the following command:
82
-
83
- ```
84
- # vagrant plugin install vagrant-sshfs
85
- ```
86
-
87
- ### Add SSHFS Synced Folder in Vagrantfile
88
-
89
- Edit your Vagrantfile to specify a folder to mount from the host into
90
- the guest:
91
-
92
- ```
93
- config.vm.synced_folder "/path/on/host", "/path/on/guest", type: "sshfs"
94
- ```
95
-
96
- Now you can simply `vagrant up` and your folder should be mounted in
97
- the guest. For more options that you can add see the [Options](#options)
98
- section.
99
-
100
- ## Executing the `vagrant sshfs` Command
101
-
102
- The Vagrant SSHFS plugin also supports execution of the `vagrant sshfs`
103
- command from the command line. Executing this command with the `--mount`
104
- option will iterate through the Vagrant file and attempt to mount (via
105
- SSHFS) any folders that aren't already mounted in the Vagrant guest.
106
- Executing with the `--unmount` option will unmount any mounted folders.
107
-
108
- ```
109
- vagrant sshfs [--mount|--unmount] [vm-name]
110
- ```
111
-
112
- ## Options
113
-
114
- The SSHFS synced folder plugin supports a few options that can be
115
- provided in the `Vagrantfile`. The following sections describe the
116
- options in more detail.
117
-
118
- ### Generic Options
119
-
120
- The SSHFS synced folder plugin supports a few options that can be
121
- provided in the `Vagrantfile`. They are described below:
122
-
123
- - `disabled`
124
- - If set to 'true', ignore this folder and don't mount it.
125
- - `ssh_opts_append`
126
- - Add some options for the ssh connection that will be established.
127
- - See the ssh man page for more details on possible options.
128
- - `sshfs_opts_append`
129
- - Add some options for the sshfs fuse mount that will made
130
- - See the sshfs man page for more details on possible options.
131
-
132
- An example snippet from a `Vagrantfile`:
133
-
134
- ```
135
- config.vm.synced_folder "/path/on/host", "/path/on/guest",
136
- ssh_opts_append: "-o Compression=yes -o CompressionLevel=5",
137
- sshfs_opts_append: "-o auto_cache -o cache_timeout=115200",
138
- disabled: false, type: "sshfs"
139
- ```
140
-
141
- ### Options Specific to Arbitrary Host Mounting
142
-
143
- The following options are only to be used when
144
- [sharing an arbitrary host directory](#sharing-arbitrary-host-directory-to-vagrant-guest---1-of-users)
145
- with the guest. They will be ignored otherwise:
146
-
147
- - `ssh_host`
148
- - The host to connect to via SSH. If not provided this will be
149
- detected as the Vagrant host that is running the Vagrant guest.
150
- - `ssh_port`
151
- - The port to use when connecting. Defaults to port 22.
152
- - `ssh_username`
153
- - The username to use when connecting. If not provided it is
154
- detected as the current user who is interacting with Vagrant.
155
- - `ssh_password`
156
- - The password to use when connecting. If not provided and the
157
- user is not using SSH keys, then the user will be prompted for
158
- the password. Please use SSH keys and don't use this option!
159
- - `prompt_for_password`
160
- - The user can force Vagrant to interactively prompt the user for
161
- a password by setting this to 'true'. Alternatively the user can
162
- deny Vagrant from ever prompting for the password by setting
163
- this to 'false'.
164
-
165
- An example snippet from a `Vagrantfile`:
166
-
167
- ```
168
- config.vm.synced_folder "/path/on/host", "/path/on/guest",
169
- ssh_host: "somehost.com", ssh_username: "fedora",
170
- ssh_opts_append: "-o Compression=yes -o CompressionLevel=5",
171
- sshfs_opts_append: "-o auto_cache -o cache_timeout=115200",
172
- disabled: false, type: "sshfs"
173
- ```
174
-
175
- ### Options Specific to Reverse Mounting (Guest->Host Mount)
176
-
177
- If your host has the `sshfs` software installed then the following
178
- options enable mounting a folder from a Vagrant Guest into the
179
- Vagrant Host:
180
-
181
- - `reverse`
182
- - This can be set to 'true' to enable reverse mounting a guest
183
- folder into the Vagrant host.
184
-
185
- An example snippet from a `Vagrantfile` where we want to mount `/data`
186
- on the guest into `/guest/data` on the host:
187
-
188
- ```
189
- config.vm.synced_folder "/guest/data", "/data", type: 'sshfs', reverse: true
190
- ```
191
-
192
- ## FAQ
193
-
194
- Here are some answers to some frequently asked questions:
195
-
196
- ### Why do new files take time to appear inside the guest?
197
-
198
- Sometimes it can take time for files to appear on the other end of the
199
- sshfs mount. An example would be I create a file on my host system and
200
- then it doesn't show up inside the guest mount for 10 to 20 seconds.
201
- This is because of caching that SSHFS does to improve performance.
202
- Performance vs accuracy is always going to be a trade-off. If you'd
203
- like to disable caching completely you can disable caching completely
204
- by appending the `cache=no` SSHFS option to the synced folder
205
- definition in the Vagrantfile like so:
206
-
207
- ```
208
- config.vm.synced_folder "/path/on/host", "/path/on/guest",
209
- type: "sshfs", sshfs_opts_append: "-o cache=no"
210
- ```
211
-
212
- All caching options that are available to sshfs can be added/modified
213
- in this same manner.
214
-
215
- ## Appendix A: Using Keys and Forwarding SSH Agent
216
-
217
- When [sharing an arbitrary host directory](#sharing-arbitrary-host-directory-to-vagrant-guest---1-of-users)
218
- you may want a completely non-interactive experience. You can either
219
- hard code your password in the Vagrantfile or you can use SSH keys.
220
- A few guides for setting up ssh keys and key forwarding are on Github:
221
- - [Key Generation](https://help.github.com/articles/generating-ssh-keys)
222
- - [Key Forwarding](https://developer.github.com/guides/using-ssh-agent-forwarding/)
223
-
224
- The idea is that if `key1` is a key that is authorized to log in to the
225
- Vagrant host ,meaning there is an entry for `key1` in the `~/.ssh/authorized_keys`
226
- file, then you should be able to do the following to have a
227
- non-interactive experience with SSH keys and agent forwarding:
228
-
229
- Modify the Vagrantfile to forward your SSH agent:
230
-
231
- ```
232
- config.ssh.forward_agent = 'true'
233
- ```
234
-
235
- Now set up your agent and add your key to the agent:
236
-
237
- ```
238
- # eval $(ssh-agent)
239
- # ssh-add /path/to/key1
240
- ```
241
-
242
- And finally bring up your Vagrant guest:
243
-
244
- ```
245
- # vagrant up
246
- ```
247
-
248
-
249
- ## Appendix B: Development
250
-
251
- For local development of this plugin here is an example of how to build, test and install this plugin on your local machine:
252
-
253
- ```
254
- # Install development dependencies
255
- $ gem install bundler && bundle install
256
-
257
- # List available Rake tasks
258
- $ bundle exec rake -T
259
-
260
- # Run Cucumber tests
261
- $ bundle exec rake featuretests
262
-
263
- # Build the gem (gets generated in the 'pkg' directory
264
- $ bundle exec rake build
265
-
266
- # Run Vagrant in the context of the plugin
267
- $ bundle exec vagrant <command>
268
-
269
- # Install built gem into global Vagrant installation (run outside of git checkout!)
270
- $ vagrant plugin install <path to gem in pkg directory>
271
- ```