Setting Up an SSH Key for GitHub

GitHub no longer supports password authentication for Git operations over HTTPS. Let's address this by setting up an SSH connection. This guide covers generating a key pair, adding the public key to your GitHub account and configuring a repository to use SSH. It is intended for developers who care about security.

1. Generate an SSH key if you do not have one:

ssh-keygen -t ed25519 -C "ваш.email@mail.ru"

2. Add the public key in GitHub settings: GitHub Settings > SSH and GPG keys

3. Change the repository URL to SSH:

git remote set-url origin git@github.com:NEME/PROJECT.git

You can now use GitHub over SSH without entering your account password. This is more convenient and safer than password-based authentication.

For additional security:

  1. Protect SSH keys with passphrases
  2. Refresh keys regularly, at least once a year
  3. Revoke unused keys in GitHub settings

You can now continue working with the repository over an SSH connection.