14

Couldn't find the answer to this anywhere but finally figured out the problem and wanted to share the solution.

Problem: After using 1Password ssh agent, trying to git commit through a terminal on a Mac yields the following error:

error: Could not connect to socket. Is the agent running?

fatal: failed to write commit object

Solution: 1Password modifies two files where it specifies which ssh to use; ~/.gitconfig and ~/.ssh/config. After removing 1Password as the default ssh agent, these two files have to be reverted as well:

In ~/.ssh/config, remove this:

Host *
  IdentityAgent "~/Library/Group Containers/2BUA8C4S2C.com.1password/t/agent.sock"

And in your ~/.gitconfig, replace this:

[gpg "ssh"]
    program = /Applications/1Password.app/Contents/MacOS/op-ssh-sign

with this path to wherever your preferred ssh is (probably /usr/bin/ssh):

[gpg "ssh"]
    program = /usr/bin/ssh

This solution applies to both command-line git and GitHub Desktop clients.

Lucas
  • 523
  • 2
  • 10
  • 20
Ohmnitude
  • 161
  • 1
  • 7
  • 2
    This was helpful to me! As a gentle suggestion you may want to move the solution into an answer to your own question :) – serverpunk Nov 27 '22 at 21:47
  • 1
    (re-)starting 1Password as Jesper said below might have worked as well, instead of disableing 1Password as SSH agent. – Marten Jan 28 '23 at 15:30

3 Answers3

34

I noticed that my 1Password wasn't running. So I started my 1Password application and it worked right away.

  • Another 1Password-related bug I just resolved, I found this line in my `.gitconfig` was missing the `"`s around the `program` string. I replaced the quotes and retried `git commit` this re-prompted me for access and everything worked again! ```program = "/Applications/1Password.app/Contents/MacOS/op-ssh-sign"``` – froboy Apr 17 '23 at 14:11
6

This error probably means that you've set up 1Password to sign your commits, most likely involving a fingerprint reader. But you have been signed out of 1Password.

Log back in to 1Password and it should work again!

Olemak
  • 2,005
  • 1
  • 17
  • 20
-3

The following is applicable to a Linux operating system. It is similar for MacOs

  1. Remove the following lines
Host *
    IdentityAgent ~/.1password/agent.sock

from the ~/.ssh/config file

  1. Remove the following lines
[gpg "ssh"]
  program = "/opt/1Password/op-ssh-sign"

from the ~/.gitconfig file

Thomas
  • 1
  • 1