Posts

🔐 Fixing “Permission Denied (publickey)” While Using Multiple GitHub Accounts

If you’ve ever tried cloning a repository and encountered this error: git@github.com: Permission denied (publickey). fatal: Could not read from remote repository. you’re not alone. This commonly happens when using multiple GitHub accounts with SSH keys . The issue usually isn’t with the repository — it’s with which SSH key Git is using. In this blog, we’ll break down: Why this error happens How SSH selects keys How to properly configure multiple GitHub accounts The clean, professional fix 🚨 Why the Error Happens When you run: git clone git@github.com:username/repo.git SSH uses the default configuration for github.com . If you have multiple SSH keys (e.g., personal, college, work), SSH may try the wrong key. GitHub then rejects the authentication request because that key is not associated with the target account. 🔍 Identifying the Problem Run: ssh -T git@github.com -v Look for: Offering public key: /Users/yourname/.ssh/id_ed25519 If the wrong key is being offered, GitHub will ...