Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Establish SSH Connection to GitHub | Introduction to the Course
Professional Web API with Flask

Establish SSH Connection to GitHubEstablish SSH Connection to GitHub

Establishing a secure SSH connection to GitHub on your Mac involves several steps, including generating an SSH key, adding the key to the SSH agent, and then adding the SSH key to your GitHub account. Here's a step-by-step guide:

Open Terminal:

You can find the Terminal application in your Applications folder, under Utilities, or use Spotlight (Cmd + Space) to search for it.

Check for Existing SSH Keys:

First, you should check if you already have SSH keys on your Mac. Type the following command in the Terminal:

Look for files named either id_rsa.pub, id_ecdsa.pub, id_ed25519.pub, or similar. If you don't have an existing key, or you want to create a new one, proceed to the next step.

Generate a New SSH Key:

To generate a new SSH key, enter the command:

Replace your_email@example.com with your GitHub email address. When prompted to "Enter a file in which to save the key," press Enter to accept the default file location. At the prompt, type a secure passphrase. You can also leave the passphrase empty for easier use, but it's less secure.

Add Your SSH Key to the SSH Agent:

First, ensure that the SSH agent is running with:

Then, add your SSH key to the SSH agent:

If you used a different name for your key file, replace id_ed25519 with the name of your key file.

Copy the SSH Key to Your Clipboard:

To copy the SSH key to your clipboard, use the command:

This copies the content of the id_ed25519.pub file to your clipboard.

Add the SSH Key to Your GitHub Account:

  • Go to GitHub and sign in;
  • Click on your profile photo in the top right corner, then click Settings;
  • In the user settings sidebar, click SSH and GPG keys;
  • Click New SSH key or Add SSH key;
  • In the "Title" field, add a descriptive label for the new key, like "Macbook Pro";
  • Paste your key into the "Key" field (it should already be in your clipboard);
  • Click Add SSH key.

Test Your SSH Connection:

To test your connection, run:

If you see a message like "Hi username! You've successfully authenticated, but GitHub does not provide shell access," then your SSH key is working correctly.

Switching remote URLs from HTTPS to SSH:

List your existing remotes in order to get the name of the remote you want to change:

Receive:
> origin https://github.com/OWNER/REPOSITORY.git (fetch)
> origin https://github.com/OWNER/REPOSITORY.git (push) Change your remote's URL from HTTPS to SSH with the command:

Verify that the remote URL has changed.

Receive:
> origin git@github.com:OWNER/REPOSITORY.git (fetch)
> origin git@github.com:OWNER/REPOSITORY.git (push)

These skills will come in handy in your programming position, and feel free to add the knowledge of using GitHub to your resume.

¿Todo estuvo claro?

Sección 1. Capítulo 7
course content

Contenido del Curso

Professional Web API with Flask

Establish SSH Connection to GitHubEstablish SSH Connection to GitHub

Establishing a secure SSH connection to GitHub on your Mac involves several steps, including generating an SSH key, adding the key to the SSH agent, and then adding the SSH key to your GitHub account. Here's a step-by-step guide:

Open Terminal:

You can find the Terminal application in your Applications folder, under Utilities, or use Spotlight (Cmd + Space) to search for it.

Check for Existing SSH Keys:

First, you should check if you already have SSH keys on your Mac. Type the following command in the Terminal:

Look for files named either id_rsa.pub, id_ecdsa.pub, id_ed25519.pub, or similar. If you don't have an existing key, or you want to create a new one, proceed to the next step.

Generate a New SSH Key:

To generate a new SSH key, enter the command:

Replace your_email@example.com with your GitHub email address. When prompted to "Enter a file in which to save the key," press Enter to accept the default file location. At the prompt, type a secure passphrase. You can also leave the passphrase empty for easier use, but it's less secure.

Add Your SSH Key to the SSH Agent:

First, ensure that the SSH agent is running with:

Then, add your SSH key to the SSH agent:

If you used a different name for your key file, replace id_ed25519 with the name of your key file.

Copy the SSH Key to Your Clipboard:

To copy the SSH key to your clipboard, use the command:

This copies the content of the id_ed25519.pub file to your clipboard.

Add the SSH Key to Your GitHub Account:

  • Go to GitHub and sign in;
  • Click on your profile photo in the top right corner, then click Settings;
  • In the user settings sidebar, click SSH and GPG keys;
  • Click New SSH key or Add SSH key;
  • In the "Title" field, add a descriptive label for the new key, like "Macbook Pro";
  • Paste your key into the "Key" field (it should already be in your clipboard);
  • Click Add SSH key.

Test Your SSH Connection:

To test your connection, run:

If you see a message like "Hi username! You've successfully authenticated, but GitHub does not provide shell access," then your SSH key is working correctly.

Switching remote URLs from HTTPS to SSH:

List your existing remotes in order to get the name of the remote you want to change:

Receive:
> origin https://github.com/OWNER/REPOSITORY.git (fetch)
> origin https://github.com/OWNER/REPOSITORY.git (push) Change your remote's URL from HTTPS to SSH with the command:

Verify that the remote URL has changed.

Receive:
> origin git@github.com:OWNER/REPOSITORY.git (fetch)
> origin git@github.com:OWNER/REPOSITORY.git (push)

These skills will come in handy in your programming position, and feel free to add the knowledge of using GitHub to your resume.

¿Todo estuvo claro?

Sección 1. Capítulo 7
some-alt