diff --git a/plugins/guests/linux/cap/insert_public_key.rb b/plugins/guests/linux/cap/insert_public_key.rb
index <HASH>..<HASH> 100644
--- a/plugins/guests/linux/cap/insert_public_key.rb
+++ b/plugins/guests/linux/cap/insert_public_key.rb
@@ -5,13 +5,13 @@ module VagrantPlugins
     module Cap
       class InsertPublicKey
         def self.insert_public_key(machine, contents)
+          contents = contents.chomp
           contents = Vagrant::Util::ShellQuote.escape(contents, "'")
-          contents = contents.gsub("\n", "\\n")
 
           machine.communicate.tap do |comm|
             comm.execute("mkdir -p ~/.ssh")
             comm.execute("chmod 0700 ~/.ssh")
-            comm.execute("printf '#{contents}' >> ~/.ssh/authorized_keys")
+            comm.execute("printf '#{contents}\\n' >> ~/.ssh/authorized_keys")
             comm.execute("chmod 0600 ~/.ssh/authorized_keys")
           end
         end
guests/linux: public key insertion is more robust

contents can have newlines (or not)