diff --git a/plugins/communicators/ssh/communicator.rb b/plugins/communicators/ssh/communicator.rb index 3d3d5a4b8..a7e1cb0ad 100644 --- a/plugins/communicators/ssh/communicator.rb +++ b/plugins/communicators/ssh/communicator.rb @@ -194,17 +194,9 @@ module VagrantPlugins f.write(priv) end - # Adjust private key file permissions - if Vagrant::Util::Platform.windows? - begin - priv_path = @machine.data_dir.join("private_key").to_s - File.set_permissions(priv_path, Etc.getlogin => File::FULL) - rescue => e - @logger.warn("Error encountered during private key permissions set - " \ - "#{e.class}: #{e.message}") - end - else - @machine.data_dir.join("private_key").chmod(0600) + # Adjust private key file permissions if host provides capability + if @machine.env.host.has_capability?(:set_ssh_key_permissions) + @machine.env.host.capability(:set_ssh_key_permissions, @machine.data_dir.join("private_key")) end # Remove the old key if it exists