diff --git a/lib/vagrant-sshfs/cap/guest/linux/sshfs_forward_mount.rb b/lib/vagrant-sshfs/cap/guest/linux/sshfs_forward_mount.rb index 4dc4a16..6b072ba 100644 --- a/lib/vagrant-sshfs/cap/guest/linux/sshfs_forward_mount.rb +++ b/lib/vagrant-sshfs/cap/guest/linux/sshfs_forward_mount.rb @@ -206,13 +206,18 @@ def self.sshfs_slave_mount(machine, opts, hostpath, expanded_guest_path) sshfs_cmd+= sshfs_opts + ' ' + sshfs_opts_append + ' ' # The ssh command to connect to guest and then launch sshfs - # Note the backslash escapes for IdentityFile - handles spaces in key path ssh_opts = opts[:ssh_opts] ssh_opts+= ' -o User=' + machine.ssh_info[:username] ssh_opts+= ' -o Port=' + machine.ssh_info[:port].to_s - ssh_opts+= ' -o "IdentityFile=\"' + machine.ssh_info[:private_key_path][0] + '\""' ssh_opts+= ' -o UserKnownHostsFile=/dev/null ' ssh_opts+= ' -F /dev/null ' # Don't pick up options from user's config + if machine.ssh_info.key?(:private_key_path) and + machine.ssh_info[:private_key_path] and + machine.ssh_info[:private_key_path][0] + # Add IdentityFile since there is one + # Note the backslash escapes for IdentityFile - handles spaces in key path + ssh_opts+= ' -o "IdentityFile=\"' + machine.ssh_info[:private_key_path][0] + '\""' + end # Use an SSH ProxyCommand when corresponding Vagrant setting is defined if machine.ssh_info[:proxy_command] diff --git a/lib/vagrant-sshfs/cap/host/darwin/sshfs_reverse_mount.rb b/lib/vagrant-sshfs/cap/host/darwin/sshfs_reverse_mount.rb index 78ae760..afe1cb9 100644 --- a/lib/vagrant-sshfs/cap/host/darwin/sshfs_reverse_mount.rb +++ b/lib/vagrant-sshfs/cap/host/darwin/sshfs_reverse_mount.rb @@ -74,6 +74,13 @@ def self.sshfs_mount(machine, opts) ssh_opts+= ' -o "IdentityFile=\"' + machine.ssh_info[:private_key_path][0] + '\""' ssh_opts+= ' -o UserKnownHostsFile=/dev/null ' ssh_opts+= ' -F /dev/null ' # Don't pick up options from user's config + if machine.ssh_info.key?(:private_key_path) and + machine.ssh_info[:private_key_path] and + machine.ssh_info[:private_key_path][0] + # Add IdentityFile since there is one + # Note the backslash escapes for IdentityFile - handles spaces in key path + ssh_opts+= ' -o "IdentityFile=\"' + machine.ssh_info[:private_key_path][0] + '\""' + end ssh_opts_append = opts[:ssh_opts_append].to_s # provided by user diff --git a/lib/vagrant-sshfs/cap/host/linux/sshfs_reverse_mount.rb b/lib/vagrant-sshfs/cap/host/linux/sshfs_reverse_mount.rb index 8fdaefa..8d2cddf 100644 --- a/lib/vagrant-sshfs/cap/host/linux/sshfs_reverse_mount.rb +++ b/lib/vagrant-sshfs/cap/host/linux/sshfs_reverse_mount.rb @@ -67,12 +67,17 @@ def self.sshfs_mount(machine, opts) opts[:ssh_opts]+= ' -o ServerAliveInterval=30 ' # send keepalives # SSH connection options - # Note the backslash escapes for IdentityFile - handles spaces in key path ssh_opts = opts[:ssh_opts] ssh_opts+= ' -o Port=' + machine.ssh_info[:port].to_s - ssh_opts+= ' -o "IdentityFile=\"' + machine.ssh_info[:private_key_path][0] + '\""' ssh_opts+= ' -o UserKnownHostsFile=/dev/null ' ssh_opts+= ' -F /dev/null ' # Don't pick up options from user's config + if machine.ssh_info.key?(:private_key_path) and + machine.ssh_info[:private_key_path] and + machine.ssh_info[:private_key_path][0] + # Add IdentityFile since there is one + # Note the backslash escapes for IdentityFile - handles spaces in key path + ssh_opts+= ' -o "IdentityFile=\"' + machine.ssh_info[:private_key_path][0] + '\""' + end ssh_opts_append = opts[:ssh_opts_append].to_s # provided by user