Git cannot find my gpg2 file or directory Windows OS - windows

So I'm trying to sign my commits so that I can eventually send a merge request for the changes I've made.
It requires a gpg key so I downloaded Gpg4Win and generated the public gpg key I needed using Kleopatra and linked that to my GitLab. All the normal steps needed.
I configured git to my key as follows:
git config --global user.signingkey 0B613778C578
And then tried to commit, signing with the new key:
git commit -S -m "Google Tag Manager installed onto 404 error page"
Where I receive the following error:
gpg: skipped "0B613778C578": No secret key
gpg: signing failed: No secret key
error: gpg failed to sign the data
fatal: failed to write commit object
GitLab advises to use the following when receiving this message:
git config --global gpg.program gpg2
But that generates the following error:
error: cannot spawn gpg2: No such file or directory
error: gpg failed to sign the data
fatal: failed to write commit object
And this is basically where I am at. I have now idea how to get git to point to my gpg properly
This is the version of gpg I have installed:
gpg (GnuPG) 2.2.19
Any help is greatly appreciated.

Related

Problem with cloning files from git in windows

I used git in Linux but right now I have to use Windows OS. The problem is that I can not clone files.
I generate a ssh key by using the ssh-keygen -o -t rsa -b 4096 command and copied the key (the long text and added the text in the ssh key file to my git SSH-key in setting.
Then try the command :
git clone Clone with SSH
I exits with this error:
git#gitlab.liu.se: Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.

gpg "failed to write commit object"

I'm trying to enable commit signing on OS X Mojave.
git commit -S -am "Test"
The error is:
error: gpg failed to sign the data
fatal: failed to write commit object
What I tried:
gpg works fine (see below), did not install gpg1 or gpg2
Installed GPG KeyChain and added a new key (even added a separate sign-only subkey whithin)
Installed pinentry
gpg2 --clearsign works fine (generates a new .asc file for files, outputs text for plain text)
Questions I looked into and tried every option:
gpg failed to sign the data fatal: failed to write commit object [Git 2.10.0]
Git error - gpg failed to sign data
What am I doing wrong?
I also had this problem. I found a good solution.
Just try to sign a file before you commit.
$ touch a.txt
$ gpg --sign a.txt
Then, the OS will let you input the password.
If this step is OK, now you can commit by signing correctly.
I just added the key ID to the global config
list all keys:
gpg --list-keys
Select the one you added to github and set it.
git config --global user.signingkey [public key ID]
Heh, of course, right after I posted this question, I found the solution.
So my problem was that I followed this doc: https://help.github.com/en/articles/telling-git-about-your-signing-key
And set up both GPG and smimesign, when I have Git < 2.19 and no proper X.509 keys.
So I just removed the part with smimesign from global ~/.gitconfig
Try with echo "foobar" | gpg --clearsign. It should ask for your key's passphrase and return the signature.
If instead you see the following error message:
error: gpg failed to sign the data
fatal: failed to write commit object
You might want to try running export GPG_TTY=$(tty). If after testing again you're prompted for the password and it works, run this everytime on startup, adding it to ~/.bashrc, which is actually required according to gpg-agent's documentation, as mentioned in this dev.gnupg thread and which you can verify with man gpg-agent.
I also found this gitHub gist very useful.
To prompt you to enter a PIN or passphrase when required, install pinentry-mac
$ brew install pinentry-mac
$ echo "pinentry-program $(which pinentry-mac)" >> ~/.gnupg/gpg-agent.conf
$ killall gpg-agent

Checkout a git submodule in Xcode 8 Build Phase script

I have a git repo on BitBucket for a utility project and i use it as a git submodule in other projects. I wrote an Xcode Build Phase script that clones, initializes and updates the submodule but it fails cloning with this error:
Cloning into '[Location of my working copy]'...
ssh_askpass: exec(/usr/X11R6/bin/ssh-askpass): No such file or directory
Permission denied (publickey).
fatal: Could not read from remote repository.
I can do a checkout from Xcode's interface, i can do a checkout from the command line, and i can even run the same script from the command line myself, and everything works, i get prompted for my passphrase. Except when the script is run by Xcode.
I contacted BitBucket support and they pointed it out that according to the error Xcode is trying to use /usr/X11R6/bin/ssh-askpass to prompt me for the passphrase of my private key but it can't find the file (i also found that /usr/X11R6 is just a symlink to /opt/X11). They suggested that i check the following links:
https://support.rstudio.com/hc/en-us/community/posts/200660237-Using-Git-with-password-authentication-on-OS-X
https://github.com/markcarver/mac-ssh-askpass
https://github.com/theseal/ssh-askpass
I installed the missing binary from the last link using Homebrew, symlinked it to the location Xcode needs it to be and got a seemingly broken dialog box:
I also tried copying the binary instead of symlinking but it didn't make a difference.
Any ideas?
Just to make sure i ran this test to see if there's a problem with my SSH configs...
$ ssh -vT git#bitbucket.org
...but according to the results everything is OK.
The guys over at https://github.com/theseal/ssh-askpass/ helped me figure this out.
I had to install the missing ssh-askpass then add my SSH key to the agent with ssh-add -c before Xcode was launched. Adding the key while Xcode was running resulted in the Build Phase script always returning an error:
sign_and_send_pubkey: signing failed: agent refused operation
You can read the troubleshooting details here.

How do I install SSL certificates on OS X so I can clone projects from Github?

I am trying to clone a repository at Github, but I am getting SSL Certificate problems.
$ git clone https://github.com/HonzaKral/django-threadedcomments.git
Initialized empty Git repository in /Users/Bryan/work/django-threadedcomments/.git/
error: SSL certificate problem, verify that the CA cert is OK. Details:
error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed while accessing https://github.com/HonzaKral/django-threadedcomments.git/info/refs
fatal: HTTP request failed
How do I install the appropriate certificates?
EDIT: I was able to avoid the issue entirely by using git:// versus https://
Open Keychain Access, select all the certificates in "System Roots" (except those crossed out, if any), right click and export all the items into a PEM file.
Then, use git config --system http.sslCAInfo /path/to/this/file.pem. If you don't want to set this globally with --system before cloning that particular repository, you can set this path in the GIT_SSL_CAINFO environment variable (e.g. GIT_SSL_CAINFO=/path/to/this/file.pem git clone ...). This will make Git (and libcurl) use that file as the trusted CA file. (You can check the details for this option in the git-config man-page.)

error when uploading with Git

I am new to Git hub and was able to successfully create an ssh key and upload it to the website however when I type in
git push origin master
I receive the following error:
error: cannot run ssh: no such file or directory
fatal: unable to fork
I am using Cygwin on a windows Vista machine if that is also useful. Ok.. after installing openssh I now get the error:
Permission denied (publickey)
fatal: the remote end hung up unexpectedly
You do not have ssh installed within Cygwin, or it's not in your path. Make sure that you are able to run ssh --version successfully from the Cygwin prompt.
For the second error, this indicates that the key your ssh client is attempting to authenticate with is not trusted by the remote server. Verify that the public key has been successfully added to your Github profile, and also verify that the public key you've added corresponds to the private key you are attempting to use.
you have to install openssh as well. Please re-run the cygwin setup and check openssh

Resources