So, you've hit a snag with GitHub and your new Mac, huh? No worries, I've got your back! We'll sort out this SSH key mess in a jiffy. Let's roll!
First things first, let's see if you've got any SSH keys lying around. Fire up your Terminal and type:
ls -al ~/.ssh
This is like peeking into your secret SSH vault. If you see files like id_rsa.pub
or id_ed25519.pub
, you're golden. If not, no sweat, we'll make a new one.
No key? No problem. Let's forge a new one. Think of this like crafting a digital ID badge. Run this:
ssh-keygen -t ed25519 -C "[email protected]"
Replace "[email protected]"
with your email. This ties your key to your identity. Just hit Enter to all prompts, and bam, new key!
Your SSH Agent is like a digital butler holding your keys. We need to make sure it knows about your new key. Do this:
eval "$(ssh-agent -s)" ssh-add ~/.ssh/id_ed25519
Now your SSH Agent is in the know.
Next, we need to tell GitHub about this shiny new key. Copy it to your clipboard with:
pbcopy < ~/.ssh/id_ed25519.pub
Then, jump over to GitHub.com in your browser. Go to Settings > find SSH and GPG keys, and hit New SSH key. Paste your key there and give it a name that makes sense.
Almost there! Let's make sure GitHub recognizes you:
ssh -T [email protected]
If you see a welcome message with your username, you're all set!
Last bit - let's ensure Git talks to GitHub using SSH. In your repo's directory, run:
git remote set-url origin [email protected]:username/repo.git
Replace username/repo.git
with your GitHub details.
And there you have it! Give it a go, and you should be pushing to GitHub like a pro.