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.
Creating a GitHub Account
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.
Installing GitHub CLI
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 ghAfter installation, authenticate through the browser:
gh auth loginYou will see interactive prompts. Choose GitHub.com -> SSH -> browser authentication.
To confirm authentication, run:
gh auth statusGenerating and Registering an SSH Key
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.
Generate an SSH Key
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.
View the Public Key
cat ~/.ssh/id_ed25519.pubYou will see a single line starting with ssh-ed25519 AAAA.... That is the public key.
Register the Public Key with GitHub
- Click your profile icon in the upper-right corner of GitHub and choose Settings
- Select SSH and GPG keys from the left menu
- Click New SSH key
- Enter a clear title, such as
My MacBook 2026 - Paste the full public key string (
ssh-ed25519 AAAA...) into the Key field - Click Add SSH key
Test the SSH Connection
ssh -T git@github.comIf 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.. Typeyesto continue.
HTTPS vs SSH
There are two ways to access GitHub: HTTPS and SSH.
| Method | Authentication | Features |
|---|---|---|
| HTTPS | Password / token | Easy to set up, but may require authentication each time |
| SSH | SSH key pair | Requires 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.
Creating a Remote Repository
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 mainThe -u option means “set upstream,” which lets you use git push alone next time.
Checking the Setup
# 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)FAQ
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.
Summary
Authenticate with GitHub CLI, configure HTTPS or SSH for the intended use, and verify the remote URL and connection. Never share or commit private keys or authentication tokens.
This article is a general information summary and is not legal advice. Confirm practical decisions with a qualified specialist.