Sometimes on EC2 or another remote server, even with SSH agent forwarding set up, you won’t be able to use SSH on the remote machine (like pulling from a private git repo).

What tends to work is this:

  1. Restart the agent on the local machine by first running ssh-agent to get the PID, then killing the PID with kill -9 PID
  2. Log out of the instance
  3. Log back in

I’ve found that using VS Code remote can cause this issue, and sometimes the above doesn’t untangle it. A workaround is just to use VS Code remote for development and then do any SSH-touching stuff with the integrated terminal.