GitHub Setup And SSH

Set up a GitHub account connection with SSH and create a clearly named personal course repository.

Objectives

  • Explain the difference between local Git and GitHub
  • Connect GitHub with an SSH key without sharing private credentials
  • Name a personal course repository consistently

Git And GitHub Have Different Jobs

  • Git records file history, commits, and branches on your computer
  • GitHub hosts a remote copy of the repository and its pull-request discussion
  • An SSH key lets Git authenticate to GitHub without entering a password or access token for each push
  • Your GitHub username identifies the account; your assigned UCID identifies course work and may be different
  • Never upload, email, or paste a private SSH key
  • Create a GitHub account or sign in before continuing to the next slide

Name The Repository

Use this lower-case pattern:

name-the-repository-01.txt
Loading code...
  • ucid: your assigned NJIT UCID, written in lower case
  • course: a course ID such as it202, it114, it490, or it265
  • Term codes: s spring, m summer, f fall, w winter
  • The example is a pattern; replace it with your own UCID, enrolled course, and term

Create It On GitHub

  1. In GitHub, open the + menu in the upper-right corner
  2. Choose New repository
  3. Choose your personal account as the owner
  4. Enter the repository name in this format: <ucid>-<course>-<section>-<term><year>
  5. Set the repository visibility to Private
  6. Turn on Add README
  7. Select Create repository

Use the course-specific setup before adding starter files or choosing an initial branch.

GitHub new repository form

Connect With SSH

connect-with-ssh-02.sh
Loading code...
  • Add the displayed public key, ending in .pub, to your GitHub account
  • Keep the matching private key on your computer
  • Use the named github_key pair so this setup does not overwrite or reuse another SSH key
  • Follow the slides below to add the public key to GitHub before testing the connection

GitHub: Open Settings

  1. In GitHub, open your profile menu in the upper-right corner
  2. Select Settings

GitHub profile menu with Settings highlighted

GitHub: Open SSH And GPG Keys

  1. In the Settings sidebar, find the Access section
  2. Select SSH and GPG keys

You can also open github.com/settings/keys after signing in.

GitHub Settings sidebar with SSH and GPG keys highlighted

GitHub: Add The Public Key

  1. Select New SSH key
  2. Give the key a title that identifies this computer, such as Personal laptop
  3. Keep Authentication Key selected
  4. Copy the complete output from cat ~/.ssh/github_key.pub into the Key field
  5. Select Add SSH key

Never paste the private github_key file into GitHub.

GitHub Add new SSH key form

Start The SSH Agent And Add The Key

start-the-ssh-agent-and--03.sh
Loading code...
  • eval "$(ssh-agent -s)" starts the SSH agent for the current terminal
  • ssh-add makes the private github_key available to Git
  • ssh-add -l confirms that the agent has loaded the key
  • The ~ path starts from the home directory, so it avoids problems with spaces in the full folder path
Note:

If eval "$(ssh-agent -s)" fails in Git Bash, run exec ssh-agent bash, then repeat the ssh-add commands.

Test The GitHub Connection

test-the-github-connecti-04.sh
Loading code...
  • Run this only after the public key has been added to GitHub
  • A successful test identifies the GitHub account that accepted the key
  • If the account is unexpected, stop and correct the account or key before cloning or pushing

Common Troubleshooting

ProblemSolution
Permission denied (publickey)Run ssh -T git@github.com, then confirm the public key belongs to the signed-in GitHub account
Wrong GitHub accountInspect the account shown by the SSH test before cloning or pushing
A repository already existsOpen the existing repository rather than creating another similarly named copy

Knowledge Check 1/2

Questions

  1. What does local Git record?
  2. What does GitHub provide for a repository?
  3. What is the correct repository name for UCID ab123, IT000, section 001, fall 2026?

Answers

  1. File history, commits, and branches on the local computer
  2. A remote repository and pull-request discussion
  3. ab123-it000-001-f2026

Use Next to reveal each answer

Knowledge Check 2/2

Questions

  1. Which SSH key is safe to add to GitHub?
  2. Which command verifies the GitHub account connection?
  3. Why use a named github_key pair instead of the default id_ed25519 name?
  4. What does ssh-add -l confirm?

Answers

  1. The public key ending in .pub
  2. ssh -T git@github.com
  3. It avoids accidentally reusing or overwriting another SSH key
  4. That the SSH agent has loaded github_key

Use Next to reveal each answer

Key Terms And Further Learning

  • Remote repository: A GitHub copy used to share and review repository history.
  • SSH public key: The shareable half of a key pair that GitHub uses to recognize the account.
  • SSH private key: The secret half that stays on the student’s computer.

Further Learning:

Summary

  • Git records local history; GitHub hosts and reviews remote history
  • Use a private repository named <ucid>-<course>-<section>-<term><year>
  • Add only the SSH public key to GitHub and verify the connection

Next presentation: Local Git Workflow And Course Repositories