Skip to content

git-crypt: This repository contains a malformed key file. It may be corrupted. #230

Description

@pantelis-karamolegkos

Trying to add a new git-crypt collaborator as follows.

Following steps run on a MacOS Big Sur with

▶ gpg --version
gpg (GnuPG) 2.3.3
libgcrypt 1.9.4
Copyright (C) 2021 Free Software Foundation, Inc.
License GNU GPL-3.0-or-later <https://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Home: /Users/pantelis/.gnupg
Supported algorithms:
Pubkey: RSA, ELG, DSA, ECDH, ECDSA, EDDSA
Cipher: IDEA, 3DES, CAST5, BLOWFISH, AES, AES192, AES256, TWOFISH,
        CAMELLIA128, CAMELLIA192, CAMELLIA256
AEAD: EAX, OCB
Hash: SHA1, RIPEMD160, SHA256, SHA384, SHA512, SHA224
Compression: Uncompressed, ZIP, ZLIB, BZIP2

1 Create the key for a specific user id

gpg --full-generate-key -u foo@bar.com

Provided rest of the details interactively. RSA key was selected

2

I switch to the working tree of my GH repo containing encrypted files. I am a git-crypt collaborator so I am able to add the new user

git-crypt add-gpg-user --trusted foo@bar.com

3

Run a GH PR with the above change, where GH does recognise that a new git-crypt collaborator was added, since I see the following message automatically being created in the PR

New collaborators:

AF23912 Foo Bar <foo@bar.com>

4

I export locally the new user's private key

gpg --export-secret-keys foo@bar.com > private.key

5

I scp this private key to another machine running Debian 9 and

$ gpg --version
gpg (GnuPG) 2.1.18
libgcrypt 1.7.6-beta
Copyright (C) 2017 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Home: /home/pantelis/.gnupg
Supported algorithms:
Pubkey: RSA, ELG, DSA, ECDH, ECDSA, EDDSA
Cipher: IDEA, 3DES, CAST5, BLOWFISH, AES, AES192, AES256, TWOFISH,
        CAMELLIA128, CAMELLIA192, CAMELLIA256
Hash: SHA1, RIPEMD160, SHA256, SHA384, SHA512, SHA224
Compression: Uncompressed, ZIP, ZLIB, BZIP2

so next steps are executed running the above gpg version

6

I import the key that was copied during step 5

$ gpg --import private.key

gpg: key XXXXXXXX: public key "Foo Bar <foo@bar.com>" imported
gpg: key XXXXXXXX: secret key imported
gpg: Total number processed: 1
gpg:               imported: 1
gpg:       secret keys read: 1
gpg:   secret keys imported: 1

7

I clone the repo (I have an ssh private key for this job

$ git clone git@github.com/MyUsername/MyRepo

8

I cd into the new dir and try to perform a decryption

$ cd MyRepo
$ git-crypt unlock

git-crypt: This repository contains a malformed key file.  It may be corrupted.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions