Skip to main content

Command Palette

Search for a command to run...

Secure GitHub Authentication with SSH

Published
3 min readView as Markdown

When cloning a GitHub repository, you have three authentication options:

  • HTTPS
  • SSH
  • GitHub CLI

This guide focuses on SSH authentication, explaining its security benefits and implementation.

What is SSH?

SSH (Secure Shell) is a network protocol that enables secure communication with remote systems. Unlike Telnet and FTP, which transmit data in plain text, SSH uses public-key cryptography to enhance security.

Public & Private Key Authentication

SSH authentication is based on a key pair: a public key and a private key. This asymmetric encryption system provides stronger security than password-based authentication.

How Does It Work?

  • Public Key: Stored on the remote server (e.g., GitHub). It can only decrypt data encrypted by the paired private key.
  • Private Key: Kept on the local machine. It should never be shared.

SSH Authentication Process

  1. Client requests SSH connection (git clone or ssh -T git@github.com).
  2. GitHub requests proof of identity by asking the client to sign a challenge with its private key.
  3. Client signs the challenge with the private key and sends it back.
  4. GitHub verifies the signature using the registered public key.

The private key itself is never transmitted, ensuring secure authentication.

The Role of Fingerprints

SSH servers must be verified for authenticity. This is where fingerprints come into play.

What is a Fingerprint?

  • A fingerprint is a hashed version of the server’s public key.
  • The client stores this fingerprint in the known_hosts file.
  • When reconnecting, SSH compares the stored fingerprint to verify the server’s identity.

Why is This Important?

  1. First-time connections store the fingerprint in ~/.ssh/known_hosts.
  2. Subsequent connections automatically verify the server.
  3. If the fingerprint matches, authentication proceeds without warnings.

Setting Up SSH Authentication

1. Generate an SSH Key

ssh-keygen -t ed25519 -C "your_email@example.com"
  • ~/.ssh/id_ed25519 → Private key (do not share!).
  • ~/.ssh/id_ed25519.pub → Public key (upload to GitHub).

2. Add the Public Key to GitHub

  1. Go to GitHub → Settings → SSH and GPG keys → New SSH key.
  2. Copy-paste the contents of id_ed25519.pub.
  3. Save and test the connection:
ssh -T git@github.com

SSH Authentication in Action

Step 1: Server Sends a Challenge

  • GitHub generates a random nonce and sends it to the client.

    Server → Client: "Sign this with your private key!"

Step 2: Client Signs the Challenge

  • The client encrypts the nonce with its private key and returns it.

    Client → Server: "Here’s the signed challenge!"

Step 3: Server Verifies the Signature

  • The server decrypts the response using the public key.
  • If the result matches the original nonce, authentication succeeds.

    Server: "The signed challenge is valid! Access granted."

Security Considerations

Why Is the Public Key Safe to Share?

  • The public key is designed to be publicly accessible.
  • Authentication is only possible with the corresponding private key.

What Happens If the Private Key Is Compromised?

  • Attackers could gain access to your account.
  • Solution: Use a passphrase when generating your key.

Conclusion

  • SSH authentication is more secure than passwords.
  • Public-key cryptography ensures that only trusted clients can authenticate.
  • Fingerprints prevent man-in-the-middle attacks by verifying server identities.

Additional Notes

  • Fingerprints are one-way hashes; they cannot be reversed to reveal the public key.
  • Even if a fingerprint matches, SSH still completes the authentication process to ensure security.

By using SSH, you enhance both security and convenience in GitHub authentication.

More from this blog

SSH를 이용한 GitHub 인증 과정 정리

GitHub에서 레포지토리를 클론(clone)하는 방법에는 세 가지가 있다: HTTPS SSH GitHub CLI 오늘은 이 중에서 SSH를 활용한 인증 과정과 보안 개념을 정리해보겠다. SSH란 무엇인가? SSH(Secure Shell)는 원격 시스템과 안전하게 통신할 수 있도록 하는 네트워크 프로토콜이다. 기존의 Telnet, FTP 같은 프로토콜은 데이터를 암호화하지 않고 전송하기 때문에 보안에 취약했지만, SSH는 비대칭 암호화(...

Feb 4, 20253 min read12

가디언 번역&요약 뉴스레터 서비스 구축기

나디언 뉴스레터 기획, 개발 과정을 요약하였습니다. 기획 의도 1. 왜 만들게 되었는가? 저는 언론 기사를 읽는걸 즐겨하는데요, 국내 언론사 기사는 토픽이 한정적이며, 필터링된 정보만 제공되다 보니 세세한 내용이 누락되는 것이 아쉬웠습니다. 그렇다보니 여러 외신을 읽는걸 시도하고 있는데, 다음과 같은 문제점들을 마주했습니다. 제가 느낀 문제점(Problem): 영어로 된 원문 기사는 읽는 데 시간이 오래 걸린다. 기사를 읽었지만 부수적인 ...

Feb 3, 20255 min read145
T

Tech Life Journey

4 posts

show a life journey covered by building, coding, and making.