diff --git a/lib/util/git/private-key.spec.ts b/lib/util/git/private-key.spec.ts
index f5fe50ac5589b31c404dbfbef1f8b03f8dab3306..1f365b0f5e544ae4793ef492d33b1712d2fd238d 100644
--- a/lib/util/git/private-key.spec.ts
+++ b/lib/util/git/private-key.spec.ts
@@ -89,7 +89,8 @@ describe('util/git/private-key', () => {
 -----BEGIN OPENSSH PRIVATE KEY-----
 some-private-key with-passphrase
 some-private-key with-passphrase
------END OPENSSH PRIVATE KEY-----`);
+-----END OPENSSH PRIVATE KEY-----
+`);
       await expect(writePrivateKey()).rejects.toThrow();
     });
 
@@ -98,7 +99,8 @@ some-private-key with-passphrase
 -----BEGIN OPENSSH PRIVATE KEY-----
 some-private-key
 some-private-key
------END OPENSSH PRIVATE KEY-----`;
+-----END OPENSSH PRIVATE KEY-----
+`;
       const privateKeyFile = upath.join(os.tmpdir() + '/git-private-ssh.key');
       const publicKeyFile = `${privateKeyFile}.pub`;
       const publicKey = 'some-public-key';
diff --git a/lib/util/git/private-key.ts b/lib/util/git/private-key.ts
index 5e929479366a280c58b898f498a0f582b67a0f5a..2b8828e6064146a9aa056a4c3ae24862469fa406 100644
--- a/lib/util/git/private-key.ts
+++ b/lib/util/git/private-key.ts
@@ -24,7 +24,7 @@ abstract class PrivateKey {
   protected abstract readonly gpgFormat: string;
 
   constructor(key: string) {
-    this.key = key.trim();
+    this.key = key;
     addSecretForSanitizing(this.key, 'global');
     logger.debug(
       'gitPrivateKey: successfully set (but not yet written/configured)',
@@ -57,6 +57,10 @@ abstract class PrivateKey {
 class GPGKey extends PrivateKey {
   protected readonly gpgFormat = 'openpgp';
 
+  constructor(key: string) {
+    super(key.trim());
+  }
+
   protected async importKey(): Promise<string | undefined> {
     const keyFileName = upath.join(os.tmpdir() + '/git-private-gpg.key');
     await fs.outputFile(keyFileName, this.key);