From a1215ea1b87cdc7fe450bd4ee2d89e49d6db3dae Mon Sep 17 00:00:00 2001 From: Dusty Mabe Date: Sun, 11 Feb 2018 16:38:57 -0500 Subject: [PATCH] ssh-config: disallow adding keys to agent If a user has set AddKeysToAgent=yes in their ssh config then the temporary SSH key that vagrant creates could get added to their agent each time an SSHFS mount is performed for a different machine. Let's disable that. Fixes #88 --- lib/vagrant-sshfs/cap/guest/linux/sshfs_forward_mount.rb | 1 + lib/vagrant-sshfs/cap/host/darwin/sshfs_reverse_mount.rb | 1 + lib/vagrant-sshfs/cap/host/linux/sshfs_reverse_mount.rb | 1 + 3 files changed, 3 insertions(+) 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 6b072ba..4cbfafc 100644 --- a/lib/vagrant-sshfs/cap/guest/linux/sshfs_forward_mount.rb +++ b/lib/vagrant-sshfs/cap/guest/linux/sshfs_forward_mount.rb @@ -81,6 +81,7 @@ def self.sshfs_forward_mount_folder(machine, opts) # Add in some ssh options that are common to both mount methods opts[:ssh_opts] = ' -o StrictHostKeyChecking=no '# prevent yes/no question opts[:ssh_opts]+= ' -o ServerAliveInterval=30 ' # send keepalives + opts[:ssh_opts]+= ' -o AddKeysToAgent=no' # don't add keys to Agent #88 # Do a normal mount only if the user provided host information if opts.has_key?(:ssh_host) and opts[:ssh_host] 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 afe1cb9..bc0aca3 100644 --- a/lib/vagrant-sshfs/cap/host/darwin/sshfs_reverse_mount.rb +++ b/lib/vagrant-sshfs/cap/host/darwin/sshfs_reverse_mount.rb @@ -66,6 +66,7 @@ def self.sshfs_mount(machine, opts) # Add in some ssh options that are common to both mount methods opts[:ssh_opts] = ' -o StrictHostKeyChecking=no '# prevent yes/no question opts[:ssh_opts]+= ' -o ServerAliveInterval=30 ' # send keepalives + opts[:ssh_opts]+= ' -o AddKeysToAgent=no' # don't add keys to Agent #88 # SSH connection options # Note the backslash escapes for IdentityFile - handles spaces in key path 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 8d2cddf..d5d4d05 100644 --- a/lib/vagrant-sshfs/cap/host/linux/sshfs_reverse_mount.rb +++ b/lib/vagrant-sshfs/cap/host/linux/sshfs_reverse_mount.rb @@ -65,6 +65,7 @@ def self.sshfs_mount(machine, opts) # Add in some ssh options that are common to both mount methods opts[:ssh_opts] = ' -o StrictHostKeyChecking=no '# prevent yes/no question opts[:ssh_opts]+= ' -o ServerAliveInterval=30 ' # send keepalives + opts[:ssh_opts]+= ' -o AddKeysToAgent=no' # don't add keys to Agent #88 # SSH connection options ssh_opts = opts[:ssh_opts]