Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Signing Git Commits on Remote VSCode Session

I am currently developing code on a remote server by using Visual Studio Code's remote SSH feature to remotely edit code using VSCode that is running on my local machine. Local machine is on Mac OS X Catalina 10.15.5, while the remote server is running Ubuntu 20.02 inside WSL2.

When I try to create a regular commit in VSCode, it works as expected. However, when I try to autosign the commit, the following error appears after clicking on the "commit" button in VSCode:

Git: gpg failed to sign the data

In order to create a signed commit remotely, I had to run the following in the VSCode terminal:

git commit -S -m "my commit msg"

which brings up the full screen UI in the terminal

┌────────────────────────────────────────────────────────────────┐
│ Please enter the passphrase to unlock the OpenPGP secret key:  │
│ "Nyxynyx <[email protected]>"                                 │
│ 4096-bit RSA key, ID B22A24D512345678,                         │
│ created 2001-01-08.                                            │
│                                                                │
│                                                                │
│ Passphrase: ****************__________________________________ │
│                                                                │
│         <OK>                                    <Cancel>       │
└────────────────────────────────────────────────────────────────┘

Entering the correct passphrase allowed the commit to be signed.

Question: Is there a way to create a signed commit using only VSCode UI and without using the terminal?

like image 834
Nyxynyx Avatar asked Jun 06 '20 06:06

Nyxynyx


1 Answers

After digging a while, I found two solutions:

  1. If you are using VSCode on Windows, and the project is on WSL2

Here you have access to your C: drive, and you can edit your ~/.gitconfig and set the gpg.program to the same you use when you are on windows, like this:

[gpg]
    program = /mnt/c/Program Files (x86)/GnuPG/bin/gpg.exe
  1. You are working with VSCode on some remote workspace.

The only solution I found besides using the terminal is installing the extension called "vscode-gpg-indicator". Follow the instructions, and you'll get a locker in your status bar, where you can unlock the GPG key before starting the commit.

like image 182
franzbischoff Avatar answered Sep 21 '22 16:09

franzbischoff