Skip to main content
Mobile Launcher

GitHub SSH Setup

Set up SSH keys for secure Git authentication

GitHub SSH Setup

SSH keys let you authenticate with GitHub without entering your password every time you push or pull.

Why SSH?

  • No password prompts when pushing/pulling
  • More secure than HTTPS with passwords
  • Required for automated deployments

Step 1: Check for Existing Keys

First, check if you already have SSH keys:

ls -al ~/.ssh

If you see id_ed25519.pub or id_rsa.pub, you already have keys. Skip to Step 4.


Step 2: Generate SSH Key

Open Terminal and run:

ssh-keygen -t ed25519 -C "your_email@example.com"

Replace your_email@example.com with your GitHub email.

Follow the prompts:

Plaintext
Enter file in which to save the key (/Users/you/.ssh/id_ed25519): [Press Enter]
Enter passphrase (empty for no passphrase): [Enter passphrase or press Enter]
Enter same passphrase again: [Confirm passphrase]

Passphrase: Optional but recommended. Adds extra security if someone accesses your computer.

Open Git Bash or PowerShell and run:

ssh-keygen -t ed25519 -C "your_email@example.com"

Follow the prompts to save the key and set a passphrase.


Step 3: Add Key to SSH Agent

Start SSH Agent

eval "$(ssh-agent -s)"

Add Key to Agent

ssh-add --apple-use-keychain ~/.ssh/id_ed25519

Configure SSH (Optional)

Create ~/.ssh/config for automatic key loading:

nano ~/.ssh/config

Add:

Plaintext
Host github.com
  AddKeysToAgent yes
  UseKeychain yes
  IdentityFile ~/.ssh/id_ed25519

Save with Ctrl+O, exit with Ctrl+X.

Start SSH Agent

In PowerShell (Admin):

Get-Service -Name ssh-agent | Set-Service -StartupType Manual Start-Service ssh-agent

Add Key to Agent

ssh-add ~/.ssh/id_ed25519

Start SSH Agent

eval "$(ssh-agent -s)"

Add Key to Agent

ssh-add ~/.ssh/id_ed25519

Step 4: Add Key to GitHub

Copy Your Public Key

pbcopy < ~/.ssh/id_ed25519.pub
Get-Content ~/.ssh/id_ed25519.pub | Set-Clipboard

Or manually copy:

cat ~/.ssh/id_ed25519.pub
cat ~/.ssh/id_ed25519.pub

Select and copy the output.

Open GitHub Settings

  1. Go to github.com and sign in
  2. Click your profile photo (top right)
  3. Click Settings

GitHub Settings Menu

  1. In the left sidebar, click SSH and GPG keys
  2. Click New SSH key

GitHub SSH and GPG Keys Settings

Add Your Key

  1. Title: Enter a name (e.g., "MacBook Pro", "Work Laptop")
  2. Key type: Keep as "Authentication Key"
  3. Key: Paste your public key

GitHub Add New SSH Key Form

  1. Click Add SSH key
  2. Confirm with your GitHub password if prompted

Step 5: Test Connection

Verify your SSH setup:

ssh -T git@github.com

First time connecting? You'll see:

Plaintext
The authenticity of host 'github.com' can't be established.
Are you sure you want to continue connecting (yes/no)?

Type yes and press Enter.

Success message:

Plaintext
Hi username! You've successfully authenticated, but GitHub does not provide shell access.

This message is normal and means SSH is working correctly.


Using SSH for Git Operations

Clone with SSH

When cloning repositories, use the SSH URL:

# SSH (recommended) git clone git@github.com:chohra-med/aimobileLauncher_standart.git # Instead of HTTPS git clone https://github.com/chohra-med/aimobileLauncher_standart.git

Get SSH URL from GitHub

  1. Go to the repository on GitHub
  2. Click the green Code button
  3. Select SSH tab
  4. Copy the URL

GitHub Clone Repository with SSH Option

Update Existing Repository

If you cloned with HTTPS, switch to SSH:

# Check current remote git remote -v # Update to SSH git remote set-url origin git@github.com:username/repo.git # Verify change git remote -v

Common Issues

IssueSolution
"Permission denied (publickey)"Ensure key is added to GitHub and SSH agent
"Could not open connection to agent"Run eval "$(ssh-agent -s)"
"Bad configuration option: usekeychain"Remove UseKeychain line (Linux only)
Key not working after restartAdd SSH config file (see Step 3)

Debug SSH Connection

ssh -vT git@github.com

This shows detailed connection info to help troubleshoot.


Quick Reference

# Generate key ssh-keygen -t ed25519 -C "email@example.com" # Start agent eval "$(ssh-agent -s)" # Add key to agent ssh-add ~/.ssh/id_ed25519 # Copy public key (macOS) pbcopy < ~/.ssh/id_ed25519.pub # Test connection ssh -T git@github.com # Clone with SSH git clone git@github.com:chohra-med/aimobileLauncher_standart.git