MirrorNest
← Все руководства

Git + SSH key authentication setup

Install Git and generate an SSH key pair for authenticating with GitHub/GitLab/Bitbucket without typing a password on every push.

Система: Windows / MacOS / LinuxDevelopmentVersion ControlОфициальный сайт ↗Официальная документация ↗
Это руководство составлено на основе официальной документации Git + SSH key authentication setup, ссылка на которую есть выше — всегда сверяйте точные названия пакетов/версий там перед запуском этих команд на рабочем сервере, так как версии дистрибутива и проекта со временем меняются.
  1. 1Install Git

    # Windows winget install --id Git.Git -e
    # MacOS brew install git
    # Ubuntu/Debian sudo apt install git
  2. 2Set your name and email

    These appear on every commit you make -- use the same email as your GitHub/GitLab account so commits link to your profile.

    git config --global user.name "Your Name"
    git config --global user.email "[email protected]"
  3. 3Generate an SSH key pair

    ssh-keygen -t ed25519 -C "[email protected]"

    Press Enter to accept the default file location. Ed25519 is the modern, recommended key type -- use `-t rsa -b 4096` only if a specific service requires RSA.

  4. 4Add the key to the SSH agent

    eval "$(ssh-agent -s)"
    ssh-add ~/.ssh/id_ed25519
  5. 5Copy the public key and add it to your Git host

    Paste the copied key into GitHub/GitLab/Bitbucket's SSH keys settings page, then verify:

    # MacOS pbcopy < ~/.ssh/id_ed25519.pub
    # Windows (PowerShell) Get-Content ~/.ssh/id_ed25519.pub | Set-Clipboard
    # Linux cat ~/.ssh/id_ed25519.pub
  6. 6Test the connection

    ssh -T [email protected]