ProgramGuru

Authenticate to GitHub with HTTPS or SSH

Authenticate to GitHub with HTTPS or SSH

Your Git commit identity tells history who authored a commit. Authentication answers a different question: are you allowed to read or write this GitHub repository?

What you’ll learn

  • Separate commit identity from authentication.
  • Recognize HTTPS and SSH remote URLs.
  • Keep tokens and private keys out of repositories.

Two common authenticated transport paths

  1. HTTPS

    Use GitHub CLI, credential helper or token-based auth.

    https://github.com/...
  2. SSH

    Use a private/public key pair.

    git@github.com:...
  3. Repository

    Both transports exchange Git objects with access checks.

    authorized fetch/push
authorized fetch/push

Identity in commits is not login authentication

For Git operations over HTTPS, GitHub supports secure authentication such as GitHub CLI, credential helpers and personal access tokens; password-based Git authentication has been removed. For SSH, you use a key pair and add the public key to GitHub.

GitHub CLI can guide authentication with gh auth login. Keep tokens and private keys secure. A public SSH key may be uploaded; the private key stays on your machine.

Choose one authentication path

Run this in a disposable practice repository unless the lesson explicitly says otherwise.

gh auth login

git remote -v

# SSH connectivity check after setup:
ssh -T git@github.com

The exact prompts depend on your environment. HTTPS and SSH are both valid; choose based on organization policy, firewall constraints and your tooling.

Practice: GitHub authentication

Your task: Inspect one repository's remote URL and determine whether it uses HTTPS or SSH. Explain which authentication mechanism that choice implies.

Common pitfall to avoid

Never commit personal access tokens, passwords or SSH private keys. If a token is exposed, revoke/rotate it. Prefer platform credential storage over plain-text credential files.

Check your understanding

Which statement is correct about GitHub command-line authentication?
Choose one answer. You can try again.

Answer and explanation

HTTPS and SSH are both supported, but they use different authentication mechanisms.

Correct.

GitHub authentication: what to remember

Authenticate to GitHub with HTTPS or SSH is complete when you can explain the state being changed before you run the command, not merely repeat the syntax.

Read further: official supporting documentation.

Reaching the recap and completing the quizzes are separate milestones.

    Next lesson: Open a pull request that is easy to review →