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:
- Restart the agent on the local machine by first running
ssh-agentto get the PID, then killing the PID withkill -9 PID - Log out of the instance
- 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.