Protocol: Connecting a Mac Computer to GitHub via Terminal (SSH Method) and Publishing Posts

Purpose:

This protocol provides a step-by-step guide for setting up and using Git on a Mac to connect to GitHub using SSH. It is designed for lab members who need to track and share their research code, analysis, and documentation on GitHub without relying on the GitHub Desktop application. With this method, you can communicate with Github via Mac’s terminal.

Setting up the connection for the first time

1. Prerequisites

  1. You have a GitHub account.
  2. You know the URL of your GitHub repository (e.g., https://github.com/Scuba-Bo/BAbramson_Lab_Notebook-Mass_Lab).
  3. Your macOS is up to date and you have internet access.

2. Check for Git Installation

  1. Open Terminal and run:
  2. git --version
  3. If not installed, install with:
  4. xcode-select --install

3. Configure Git (First-Time Setup)

  1. git config --global user.name 'Your Name'
  2. git config --global user.email 'your_email@example.com'

4. Generate an SSH Key

  1. ssh-keygen -t ed25519 -C 'your_email@example.com'
  2. Press Enter to accept the default file path, and optionally set a passphrase.

5. Add the SSH Key to GitHub

  1. Display your public key: cat ~/.ssh/id_ed25519.pub
  2. Copy the full key (starts with ssh-ed25519).
  3. Go to GitHub → Settings → SSH and GPG keys → New SSH key.
  4. Paste the key and click Add SSH key.

6. Configure SSH to Use Port 443 (for Restricted Networks)

  1. Create or edit the SSH config file: nano ~/.ssh/config
  2. Add the following lines:
     Host github.com
       HostName ssh.github.com
       User git
       Port 443
       IdentityFile ~/.ssh/id_ed25519
    
  3. Save and exit (Ctrl + O, Enter, Ctrl + X).

7. Test the SSH Connection

  1. Run: ssh -T git@github.com
  2. If successful, you’ll see: ‘Hi [YourGitHubUsername]! You’ve successfully authenticated, but GitHub does not provide shell access.’

Publishing a Post

  1. Navigate to your project folder. I recommend creating a reference document to copy and paste from for your specific pathways. Tip: when right clicking on a folder, click option to be able to copy the pathname. Here’s an example with my pathways: cd /Users/Boaz/Documents/GitHub/BAbramson_Lab_Notebook-Mass_Lab
  2. Initialize Git: git init
  3. Connect to your GitHub repo: git remote add origin git@github.com:Scuba-Bo/BAbramson_Lab_Notebook-Mass_Lab.git
  4. Optionally verify: git remote -v

9. Upload Files to GitHub

  1. If the folder is empty, create a README file: echo '# BAbramson Lab Notebook' > README.md
  2. Stage files: git add .
  3. Commit files: git commit -m 'Initial commit - add project files'
  4. Push to GitHub:
  5. git branch -M master
  6. git push -u origin master

10. Verify Successful Upload

  1. Visit your repository page on GitHub (e.g., https://github.com/Scuba-Bo/BAbramson_Lab_Notebook-Mass_Lab) to confirm files appear.
  2. You can check the status of your deployment on GitHub by clicking on the ‘Actions’ tab

Author: Boaz Abramson

Laboratory: Mass Lab

Last Edited: May 25th 2026

Written on December 14, 2025