Data Science Hub
  • Data Science Hub
  • STATISTICS
    • Introduction
    • Fundamentals
      • Data Types
      • Central Tendency, Asymmetry, and Variability
      • Sampling
      • Confidence Interval
      • Hypothesis Testing
    • Distributions
      • Exponential Distribution
    • A/B Testing
      • Sample Size Calculation
      • Multiple Testing
  • Database
    • Database Fundamentals
    • Database Management Systems
    • Data Warehouse vs Data Lake
  • SQL
    • SQL Basics
      • Creating and Modifying Tables/Views
      • Data Types
      • Joins
    • SQL Rules
    • SQL Aggregate Functions
    • SQL Window Functions
    • SQL Data Manipulation
      • String Operations
      • Date/Time Operations
    • SQL Descriptive Stats
    • SQL Tips
    • SQL Performance Tuning
    • SQL Customization
    • SQL Practice
      • Designing Databases
        • Spotify Database Design
      • Most Commonly Asked
      • Mixed Queries
      • Popular Websites For SQL Practice
        • SQLZoo
          • World - BBC Tables
            • SUM and COUNT Tutorial
            • SELECT within SELECT Tutorial
            • SELECT from WORLD Tutorial
            • Select Quiz
            • BBC QUIZ
            • Nested SELECT Quiz
            • SUM and COUNT Quiz
          • Nobel Table
            • SELECT from Nobel Tutorial
            • Nobel Quiz
          • Soccer / Football Tables
            • JOIN Tutorial
            • JOIN Quiz
          • Movie / Actor / Casting Tables
            • More JOIN Operations Tutorial
            • JOIN Quiz 2
          • Teacher - Dept Tables
            • Using Null Quiz
          • Edinburgh Buses Table
            • Self join Quiz
        • HackerRank
          • SQL (Basic)
            • Select All
            • Select By ID
            • Japanese Cities' Attributes
            • Revising the Select Query I
            • Revising the Select Query II
            • Revising Aggregations - The Count Function
            • Revising Aggregations - The Sum Function
            • Revising Aggregations - Averages
            • Average Population
            • Japan Population
            • Population Density Difference
            • Population Census
            • African Cities
            • Average Population of Each Continent
            • Weather Observation Station 1
            • Weather Observation Station 2
            • Weather Observation Station 3
            • Weather Observation Station 4
            • Weather Observation Station 6
            • Weather Observation Station 7
            • Weather Observation Station 8
            • Weather Observation Station 9
            • Weather Observation Station 10
            • Weather Observation Station 11
            • Weather Observation Station 12
            • Weather Observation Station 13
            • Weather Observation Station 14
            • Weather Observation Station 15
            • Weather Observation Station 16
            • Weather Observation Station 17
            • Weather Observation Station 18
            • Weather Observation Station 19
            • Higher Than 75 Marks
            • Employee Names
            • Employee Salaries
            • The Blunder
            • Top Earners
            • Type of Triangle
            • The PADS
          • SQL (Intermediate)
            • Weather Observation Station 5
            • Weather Observation Station 20
            • New Companies
            • The Report
            • Top Competitors
            • Ollivander's Inventory
            • Challenges
            • Contest Leaderboard
            • SQL Project Planning
            • Placements
            • Symmetric Pairs
            • Binary Tree Nodes
            • Interviews
            • Occupations
          • SQL (Advanced)
            • Draw The Triangle 1
            • Draw The Triangle 2
            • Print Prime Numbers
            • 15 Days of Learning SQL
          • TABLES
            • City - Country
            • Station
            • Hackers - Submissions
            • Students
            • Employee - Employees
            • Occupations
            • Triangles
        • StrataScratch
          • Netflix
            • Oscar Nominees Table
            • Nominee Filmography Table
            • Nominee Information Table
          • Audible
            • Easy - Audible
          • Spotify
            • Worldwide Daily Song Ranking Table
            • Billboard Top 100 Year End Table
            • Daily Rankings 2017 US
          • Google
            • Easy - Google
            • Medium - Google
            • Hard - Google
        • LeetCode
          • Easy
  • Python
    • Basics
      • Variables and DataTypes
        • Lists
        • Dictionaries
      • Control Flow
      • Functions
    • Object Oriented Programming
      • Restaurant Modeler
    • Pythonic Resources
    • Projects
  • Machine Learning
    • Fundamentals
      • Supervised Learning
        • Classification Algorithms
          • k-Nearest Neighbors
            • kNN Parameters & Attributes
          • Logistic Regression
        • Classification Report
      • UnSupervised Learning
        • Clustering
          • Evaluation
      • Preprocessing
        • Scalers: Standard vs MinMax
        • Feature Selection vs Dimensionality Reduction
        • Encoding
    • Frameworks
    • Machine Learning in Advertising
    • Natural Language Processing
      • Stopwords
      • Name Entity Recognition (NER)
      • Sentiment Analysis
        • Agoda Reviews - Part I - Scraping Reviews, Detecting Languages, and Preprocessing
        • Agoda Reviews - Part II - Sentiment Analysis and WordClouds
    • Recommendation Systems
      • Spotify Recommender System - Artists
  • Geospatial Analysis
    • Geospatial Analysis Basics
    • GSA at Work
      • Web Scraping and Mapping
  • GIT
    • GIT Essentials
    • Connecting to GitHub
  • FAQ
    • Statistics
  • Cloud Computing
    • Introduction to Cloud Computing
    • Google Cloud Platform
  • Docker
    • What is Docker?
Powered by GitBook
On this page
  • Generating an SSH key on Mac
  • Adding your SSH key to the ssh-agent
  • Add the SSH public key to your GitHub account

Was this helpful?

  1. GIT

Connecting to GitHub

Last updated 1 year ago

Was this helpful?

We can connect to git repositories in two ways: HTTPS and SSH.

  • HTTPS: asks for an access token every time we do a push to a repository.

  • SSH: enables us to use Git commands without requiring username and token.

SSH is the preferred method to communicate with GitHub in the industry and fairly simple to setup:

  1. We first need to generate an SSH key on our local machines.

  2. After generating the key, we add our public key to our account on GitHub.com

Once we complete the step 2, we will then be authenticated for Git operations over SSH.

Generating an SSH key on Mac

  1. Open Terminal.

  2. Paste the text below, replacing the email address used on your GitHub account .

    ssh-keygen -t rsa -b 4096 -C "your_email@example.com"

This creates a new SSH key, using the provided email as a label. When you're prompted to "Enter a file in which to save the key", you can press Enter to accept the default file location.

> Enter a file in which to save the key (/Users/YOU/.ssh/id_ALGORITHM): [Press enter]
  1. At the prompt, type a secure passphrase. For more information, see "."

    Enter passphrase (empty for no passphrase): [Type a passphrase]
    > Enter same passphrase again: [Type passphrase again]

Adding your SSH key to the ssh-agent

If we don't want to type our passphrase each time we use the key, we will need to add it to the ssh-agent.

  1. Start the ssh-agent in the background.

    $ eval 'ssh-agent'
    > Agent pid 59566

Depending on your environment, you may need to use a different command. For example,

  • you may need to use root access by running sudo -s -H before starting the ssh-agent,

  • or you may need to use exec ssh-agent bash or exec ssh-agent zsh to run the ssh-agent.

  1. If you're using macOS Sierra 10.12.2 or later, you will need to modify your ~/.ssh/config file to automatically load keys into the ssh-agent and store passphrases in your keychain.

  • First, check to see if your ~/.ssh/config file exists in the default location.

    $ open ~/.ssh/config
    > The file /Users/YOU/.ssh/config does not exist.
  • If the file doesn't exist, create the file.

    touch ~/.ssh/config
  • Open your ~/.ssh/config file using vim or the text editor of your preference, then modify the file to contain the following lines. If your SSH key file has a different path than the example code, modify the file path to match your current setup.

    Host github.com
      AddKeysToAgent yes
      UseKeychain yes
      IdentityFile ~/.ssh/<private_key_file>

Notes:

  • If you chose not to add a passphrase to your key, you should omit the UseKeychain line.

  • If you see a Bad configuration option: usekeychain error, add an additional line to the configuration's' Host *.github.com section.

    Host github.com
      IgnoreUnknown UseKeychain
  1. Add your SSH private key to the ssh-agent and store your passphrase in the keychain with the name of your private key file.

    ssh-add -K ~/.ssh/<private_key_file> 

In macOS versions prior to Monterey (12.0),

  • -K flag represents --apple-use-keychain

  • -A flag represents --apple-load-keychain

If you continue to be prompted for your passphrase, you may need to add the command to your ~/.zshrc file (or your ~/.bashrc or file for bash).

  1. Copy the SSH public key to your clipboard.

$ pbcopy < ~/.ssh/<public_key_file>.pub
# Copies the contents of the <public_key_file>.pub file to your clipboard

Add the SSH public key to your GitHub account

  1. Go to Profile>Settings>SSH and GPG keys.

  2. Click New SSH key or Add SSH key on the upper right corner.

  3. In the "Title" field, add a descriptive label for the new key. For example, if you're using a personal laptop, you might call this key "Personal laptop".

  1. In the "Key" field, paste your public key.

  2. Click Add SSH key.

Select the type of key, either authentication or signing. For more information about commit signing, see "."

If prompted, confirm access to your account on GitHub. For more information, see "."

Working with SSH key passphrases
About commit signature verification
Sudo mode