Skip to content
X

GitHub Account and SSH Key Setup

GitHub is a platform for storing, sharing, and collaborating on Git-managed code over the internet. Engineers around the world use it, and it is a central place for open source projects and team development.

This page explains how to create a GitHub account and set up SSH authentication so you can push and pull code safely.

Go to github.com and click Sign up.

  • Username: Visible to other developers. It does not have to be your real name, but it is common to choose something easy to recognize if you may use it as a portfolio later.
  • Email: Register the email address you use regularly.
  • Password: Set a strong password.

💡 Be sure to enable two-factor authentication (2FA). GitHub strongly recommends it for security.

GitHub CLI (gh) is a command-line tool for working with GitHub from the terminal. You can create repositories and pull requests without opening the browser.

brew install gh

After installation, authenticate through the browser:

gh auth login

You will see interactive prompts. Choose GitHub.com -> SSH -> browser authentication.

To confirm authentication, run:

gh auth status

An SSH key is an encrypted authentication method that replaces passwords. It works as a pair: a public key registered with GitHub and a private key stored on your machine. SSH lets you push and pull quickly without entering a password each time.

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

You will be asked where to save the file and whether to use a passphrase.

Enter file in which to save the key (/Users/you/.ssh/id_ed25519): [Press Enter to use the default]
Enter passphrase (empty for no passphrase): [enter a passphrase]
Enter same passphrase again: [re-enter the passphrase]

💡 Using a passphrase is recommended. It adds protection if the key file is ever exposed.

cat ~/.ssh/id_ed25519.pub

You will see a single line starting with ssh-ed25519 AAAA.... That is the public key.

  1. Click your profile icon in the upper-right corner of GitHub and choose Settings
  2. Select SSH and GPG keys from the left menu
  3. Click New SSH key
  4. Enter a clear title, such as My MacBook 2026
  5. Paste the full public key string (ssh-ed25519 AAAA...) into the Key field
  6. Click Add SSH key
ssh -T git@github.com

If you see the following, it worked:

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

⚠️ The first time you connect, you may see The authenticity of host 'github.com' can't be established.. Type yes to continue.

There are two ways to access GitHub: HTTPS and SSH.

MethodAuthenticationFeatures
HTTPSPassword / tokenEasy to set up, but may require authentication each time
SSHSSH key pairRequires initial setup, but no password is needed after that

If you set up SSH, repository URLs use the form git@github.com:username/repo.git.

Here is how to create a repository with GitHub CLI and connect it to your local repository.

# Create a repository on GitHub (use --public for public, --private for private)
gh repo create my-project --public

# Add a remote to the local repository using SSH
git remote add origin git@github.com:username/my-project.git

# Push main and set tracking
git push -u origin main

The -u option means “set upstream,” which lets you use git push alone next time.

# Check remote settings
git remote -v

# It should look like this for SSH
# origin  git@github.com:username/my-project.git (fetch)
# origin  git@github.com:username/my-project.git (push)

Q. Which should I use, HTTPS or SSH?

SSH is recommended. Once it is set up, you no longer need to enter a password each time, which makes work faster.

Q. Can I create SSH keys on multiple machines?

Yes. It is recommended to generate different SSH keys for each machine and register them in GitHub. Adding the machine name to the key title makes them easier to manage.

Q. Does gh auth login create keys automatically if I choose SSH?

Yes. If you choose SSH during the interactive gh auth login flow, it will generate the key and register it with GitHub automatically. Use the manual steps above if you want to configure it yourself.