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.

3

There are 3 best solutions below

1
On

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

3
On

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

1
On

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!