Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git commit "error: Could not connect to socket. Is the agent running? fatal: failed to write commit object" after reverting from 1password ssh-agent

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.

like image 474
Ohmnitude Avatar asked Sep 08 '25 02:09

Ohmnitude


1 Answers

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

like image 137
Jesper van den Munckhof Avatar answered Sep 09 '25 17:09

Jesper van den Munckhof