Headless Git: Authenticating with GitHub and Bitbucket via SSH

Published: January 21, 2026

← Back to Home

When working on a headless Linux server, you can’t “Sign in with Google” or “Microsoft” or handle redirects in a browser. While Windows handles this with pop-ups, Linux terminals require a different approach.

The standard for terminal-only authentication is SSH Keys using the Ed25519 algorithm.


1. Generate Your Key (The Modern Way)

Regardless of whether you use GitHub or Bitbucket, the first step is generating a modern, secure key on your Linux machine.

ssh-keygen -t ed25519 -C "your-email@gmail.com"

Once generated, show the public key so you can copy it:

cat ~/.ssh/id_ed25519.pub

2. Connect to Your Provider

Option A: GitHub (My Preferred Choice)

  1. Log into GitHub on any device with a browser.
  2. Go to Settings > SSH and GPG keys.
  3. Click New SSH Key.
  4. Give it a title (e.g., “Linux-Server”) and paste the key string from your terminal.

To Clone: Ensure you use the SSH URL format: git clone git@github.com:username/repository.git

Option B: Bitbucket (I use it with work sometimes, but I don’t care for it.)

If your organization uses Bitbucket (often behind an Okta/SSO wall):

  1. Log into Bitbucket in your browser.
  2. Click your Avatar (bottom left) > Personal settings.
  3. Under Security, click SSH keys > Add key.
  4. Paste your key and save.

To Clone: Change the clone dropdown from HTTPS to SSH. The URL will look like: git clone git@bitbucket.org:workspace/repository.git


3. Test the Connection

Before you try to clone, you can verify that the handshake works with these “Hello World” commands:

You should see a message like: “Hi username! You’ve successfully authenticated.”


4. Clone Your Repository

Now that your SSH key is set up and verified, you’re ready to clone repositories using SSH. The key difference from HTTPS is the URL format.

For GitHub:

git clone git@github.com:username/repository.git

For Bitbucket:

git clone git@bitbucket.org:workspace/repository.git

You can find the SSH URL on the repository page:

Once cloned, all your git operations (push, pull, fetch) will automatically use SSH authentication.


5. Final Touch: Set Your Git Identity

Authentication (SSH) gets you in the door, but Identity (Git Config) puts your name on the work. Run these once on your new Linux machine:

git config --global user.name "Your Full Name"
git config --global user.email "your-email@gmail.com"

Happy Coding!