BM: Baca dalam Bahasa Melayu
World 11: Rescue Center
Permission denied (publickey)
You will learn: two calm fixes when GitHub says Permission denied (publickey).
The problem
You type git push. GitHub says Permission denied. Your work is safe! GitHub just can’t tell who you are. This happens to everyone.
Watch
Your computer proves who you are with an SSH key. Test the key alone with ssh -T git@github.com. Same answer: GitHub doesn’t know this key.
Try it
What’s the most likely cause?
Pick one answer.
Try it
Put the SSH fix in order, first step at the top.
First step at the top. Put these in order. Use the arrows, or drag.
- ssh-add -l: is a key loaded?
- Add the public key (.pub) to your GitHub account
- ssh-add ~/.ssh/id_ed25519: load your key
- ssh -T git@github.com: test again
Hint
Check first. Test last.Watch
When it works, GitHub greets you by name. “No shell access” is normal. Now git push works too.
Try it
In a hurry? Switch origin to the HTTPS address. Then push again.
Hint
Typegit remote set-url origin https://github.com/you/diary.git, then git push.Predict
On a real computer, HTTPS asks you to sign in. What works as the password?
Pick one answer.
You did it!
You can now fix Permission denied (publickey), two ways.
Go deeper (optional)
No key yet? Make one with ssh-keygen -t ed25519 -C "you@example.com" (World 4). Only the .pub file goes to GitHub. Never share the private key. Using sudo git push? Drop the sudo. Your keys belong to you, not to the admin account.
Bahasa Melayu
Anda taip git push. GitHub kata Permission denied. Kerja anda selamat! GitHub cuma tak kenal siapa anda. Ini berlaku pada semua orang.
Komputer anda buktikan siapa anda dengan kunci SSH. Uji kunci itu sendirian dengan ssh -T git@github.com. Jawapan sama: GitHub tak kenal kunci ini.
Apa punca yang paling mungkin?
Susun cara baiki SSH, langkah pertama di atas.
Bila berjaya, GitHub sapa nama anda. “No shell access” itu normal. Sekarang git push pun berjaya.
Tergesa-gesa? Tukar origin ke alamat HTTPS. Kemudian push semula.
git remote set-url origin https://github.com/you/diary.git, kemudian git push.Di komputer sebenar, HTTPS minta anda log masuk. Apa yang boleh jadi kata laluan?
Kini anda boleh baiki Permission denied (publickey), dengan dua cara.
You finished this before. Practice is always welcome!
Official docs: Error: Permission denied (publickey) · Testing your SSH connection · git remote set-url
You've learned for 25 minutes. A short break helps your brain.
Sprint done! Great focus. Stretch for a minute?