How to sign git fixed in IDE like IntelliJ?

Question How do I sign git commits using an IDE such as IntelliJ on Windows?

If you're interested, read what I tried here:

I followed mainly the Github guide . I took care not to forget to restart bash / IntelliJ after you changed the configuration files.

  1. Create a new GPG key pair
  2. Add a GPG key to my GitHub account
  3. .gitconfig A verified (from GitHub) email with my GPG key, where I made sure the email in mine .gitconfigis the same.
  4. Tell Git about my GPG Key
  5. Sign the commit with GPG and confirm that it is verified on Github.
  6. On the same page, I set commits for signing by default with git config --global commit.gpgsign true(I use git 2.12). I made a new commit and confirmed that it was signed usinggit verify-commit HEAD
  7. When I try to commit in IntelliJ, I get gpg: cannot open tty 'no tty'therefore I found that IntelliJ cannot commit the changes when I try to sign a commit (GPG), and added it no-ttyto my C:\Users\username\.gnupg\gpg.conffile and restarted.

  8. Then I get an error message gpg: Sorry, no terminal at all requested - can't get inputthat seems reasonable, because I just added an option that is related to the terminal. As in gpg: Sorry, the terminal is not requested at all - I can’t get the data, because the solution is to delete no-ttywhich, I hope, does not apply to my case.

  9. use-agent gpg.conf, gpg: gpg-agent is not available in this session. , , , gpg-agent.

  10. Windows, , - Archlinux wiki (, ). C: /Users/username/.gnupg/gpg-agent.conf , default-cache-ttl 34560000 max-cache-ttl 34560000 https://superuser.com/questions/624343/keep-gnupg-credentials-cached-for-entire-user-session

  11. gpg-agent, https://superuser.com/questions/1153101/why-does-git-complain-that-no-gpg-agent-is-running , gpg-agent --version , gpg --version, gpg2, git config --global gpg.program gpg2.

  12. gpg2 . Gpg4win ( , ) Gnupg 2 , gpg2 , , GNU Program Files (x86), , , . where gpg , gpg, , . git git config --global gpg.program 'C:\Program Files (x86)\GnuPG\bin\gpg.exe' git config --global gpg.program 'C:\Program Files (x86)\GnuPG\bin\gpg.exe'

  13. gpg: skipped "keyid": secret key not available. gpg: "N": , , , . , gpg, . alias gpg="'C:\Program Files (x86)\GnuPG\bin\gpg.exe'", gpg --version . , .bash_profile .

  14. gpg --gen-key . , , , , gpg , , . Windows .

  15. ! IntelliJ, . Git Bash no secret key , , , gpg --list-keys : gpg.

  16. Intellij IDEA GIT GPG, , MAC , , Windows. :

  17. me.m01.eu GNUPGHOME C:\Users\username\.gnupg. , , git commit, : . , gpg C:\Users\username\AppData\Roaming\gnupg . printenv GNUPGHOME ( ). , .

  18. , , C:\Users\username\.gnupg , , gpg --list-keys . gpg, .

  19. gpg --list-keys --homedir='C: /Users/s156757/.gnupg' , homedir C:\Users\s156757\.gnupg C:\Users\username\AppData\Roaming\gnupg\gpg.conf C:\Users\username\AppData\Roaming\gnupg\gpg.conf . - . , gpg --list-keys . , no-tty use-agent conf .

skipped "keyid": No secret key IntelliJ, Git Bash, skipped "keyid": No secret key.

  1. gpg gpg2 gpg --export [ID] | gpg2 --import && gpg --export-secret-keys [ID] | gpg2 --import gpg --export [ID] | gpg2 --import && gpg --export-secret-keys [ID] | gpg2 --import
  2. , Gpg4win , . , Gpg4win -.
  3. , , gpg --list-secret-keys gpg 2. , gpg --list-keys.

, : gpg-agent , gpg- git gpg-agent, gpg 2. , Git Bash, IntelliJ.

+16
2

git 2.19.1, gpg2 !

gpg-agent ,

gpg . , git 2.19.1 gpg 2.2.9. Windows 7, Windows 8.1, Windows 10, Arch Linux Fedora 29.

git commit

  1. ssh, ., , help.github.com/en/articles/connecting-to-github-with-Ssh ( GitHub)
  2. ( Linux) ( Windows) git bash, git --version git 2.19.1, gpg --version gpg2.

    , where gpg ( which gpg where ), - git.

    • gpg2, gpg2 gpg, gpg2 --version. gpg2 gpg2 gpg.
    • git, , ( Windows) alias gpg="'C:\path\to\Git\usr\bin\gpg.exe'" C:\Users\username\.bash_profile, , , git bash. where gpg gpg --version. , gpg , 'C:\path\to\Git\usr\bin\gpg.exe'.
  3. gpg --version - ( Linux) /home/username/.gnupg ( windows) /c/Users/username/.gnupg. .

    , - , Windows , , , .bash_profile alias gpg="gpg --homedir=/c/Users/s156757/.gnupg" bash, .

  4. Github, , . GPG ( gnupg!): gpg --full-generate-key
    • RSA RSA 4096 .
    • user.name ~\.gitconfig.
    • user.email ~\.gitconfig, , GitHub.
    • gpg-agent ( ) GitHub, . .
  5. , , , gpg --list-Secret-keys --keyid-format LONG. , key_id ( ) sec rsa4096/key_id 2018-10-27 [SC]...
  6. gpg --armor --export key_id.
  7. GPG GitHub: Settings | SSH and GPG keys Settings | SSH and GPG keys ( ).
  8. Git GPG: git config --global user.signingkey key_id.
  9. --homedir, , git gpg, . C:\Users\username\start-gpg.sh gpg --homedir=/c/Users/s156757/.gnupg "$@". git config --global gpg.program C:\\Users\\username\\start-gpg.sh git .
  10. Bash.
  11. GPG git commit -S -m "signed commit" , Github, .
  12. git config --global commit.gpgsign true. , git verify-commit HEAD.

:

1.

2. gpg-agent

: , . :

  1. C:\Users\username\.gnupg\gpg-agent.conf: , , default-cache-ttl 34560000 max-cache-ttl 34560000.
  2. gpg-agent gpgconf --kill gpg-agent
  3. , . , Verified GitHub.

3. gpg.

, -, , GitHub Unverified . : , ,

  1. , C:\Users\username\start-gpg.sh . , , --homedir git config --global gpg.program C:\\Users\\username\\start-gpg.sh. bash.

, ! , , ...

# Passphrase-file-descriptor is set to 0 (STDIN), to use it --batch must be used
# The --pinentry-mode loopback is required since gpg 2.1.0 for --passphrase-fd
# The "$@" makes sure that whatever git wanted gpg to do, is still done
echo mypassphrase | gpg --homedir=/c/Users/username/.gnupg --passphrase-fd 0 --batch --yes --pinentry-mode loopback "$@"
  1. , , Verified GitHub.

git gpg2

, , , , , , . "" , , :

  • GitHub unverified: The key whose key-id is in the signature did not sign this commit. Someone may be trying to trick you. The key whose key-id is in the signature did not sign this commit. Someone may be trying to trick you. - , ,
  • , , .

, , , .

  1. Github: GPG
  2. GPG GitHub
  3. ( GitHub) GPG , .gitconfig .
  4. Git GPG
  5. GPG , Github, .
  6. git config --global commit.gpgsign true. , git verify-commit HEAD.

  7. gpg, git, , Gpg4win ( , ), gpg 2. where gpg , , , - gpg, - C:\Program Files (x86)\GnuPG\bin\gpg.exe. , Gnupg 2 .

  8. alias gpg="'C:\Program Files (x86)\GnuPG\bin\gpg.exe'" gpg gpg C:\Users\username\.bash_profile, Git Bash gpg --version gpg 2.

  9. GNUPGHOME C:\Users\username\.gnupg. printenv GNUPGHOME .

  10. C:\Users\username\gpg-no-tty.sh echo passphrase | "C:\Program Files (x86)\GnuPG\bin\gpg.exe" --passphrase-fd 0 --batch --no-tty --yes "$@" echo passphrase | "C:\Program Files (x86)\GnuPG\bin\gpg.exe" --passphrase-fd 0 --batch --no-tty --yes "$@"

    , , --batch, --batch, , --batch. , , , , , , - .

  11. git git config --global gpg.program C:\\Users\\username\\gpg-no-tty.sh.

  12. Git Bash IntelliJ , , , , git verify-commit HEAD.

+13

Source: https://habr.com/ru/post/1687941/


All Articles