When cloning a repository from GitHub, you have two main options for the URL protocol:
SSH and HTTPS. Both achieve the same result (i.e., cloning the repo), but they differ in
authentication, security, and ease of use.
SSH (Secure Shell)
Example URL:
git@github.com:username/repo.git
How it works:
Uses SSH keys for authentication.
Requires that you generate a public/private SSH key pair and
add the public key to your GitHub account.
Pros:
More secure for repeated use.
No need to enter your username/password or token every time.
Ideal for power users and automated environments (CI/CD, scripting).
Cons:
Requires one-time SSH key setup.
Can be tricky behind restrictive firewalls (uses port 22).
HTTPS
Example URL:
https://github.com/username/repo.git
How it works:
Uses username and password (or personal access token) for authentication.
Usually prompts for credentials unless you use a credential manager or cache them.
Pros:
Easy to use—no setup needed.
Works well behind most corporate firewalls and proxies (uses port 443).
Cons:
Requires personal access token instead of password (since GitHub no longer accepts passwords).
Prompts for credentials unless you configure a credential manager.
Slightly less convenient for frequent use or scripting.
When to Use What?
Scenario
Recommended Protocol
First-time or casual use
HTTPS
Frequent pushing/pulling
SSH
Working behind strict firewall
HTTPS
Setting up CI/CD or scripts
SSH (with key auth)
Summary
Feature
SSH
HTTPS
Auth Method
SSH key pair
Username + token
Setup Needed
Yes (once)
No (but token needed)
Credential Use
No need to re-enter
May need caching/token
Security
Strong, key-based
Secure with token
Firewall Safe
Sometimes blocked (port 22)
Usually works (port 443)
Markdown for AI
A clean, structured version of this page for AI assistants and LLMs.
We use cookies to ensure you have the best browsing experience on our website. By using our site, you
acknowledge that you have read and understood our
Cookie Policy &
Privacy Policy.
When cloning a repository from GitHub, you have two main options for the URL protocol: SSH and HTTPS. Both achieve the same result (i.e., cloning the repo), but they differ in authentication, security, and ease of use.
SSH (Secure Shell)
Example URL:
How it works:
Pros:
Cons:
HTTPS
Example URL:
How it works:
Pros:
Cons:
When to Use What?
Summary