Git SSH Keys | Atlassian Git Tutorial

Adding your ssh key to the ssh-agent

Before adding a new SSH key to the ssh-agent to manage your keys, you should have checked for existing SSH keys and generated a new SSH key. When adding your SSH key to the agent, use the default macOS ssh-add command, and not an application installed by macports, homebrew, or some other external source.

  1. Start the ssh-agent in the background.

    $ eval "$(ssh-agent -s)"
    > Agent pid 59566

    Depending on your environment, you may need to use a different command. For example, you may need to use root access by running sudo -s -H before starting the ssh-agent, or you may need to use exec ssh-agent bash or exec ssh-agent zsh to run the ssh-agent.

  2. If you’re using macOS Sierra 10.12.2 or later, you will need to modify your ~/.ssh/config file to automatically load keys into the ssh-agent and store passphrases in your keychain.

  3. Add your SSH private key to the ssh-agent and store your passphrase in the keychain. If you created your key with a different name, or if you are adding an existing key that has a different name, replace id_ed25519 in the command with the name of your private key file.

    $ ssh-add -K ~/.ssh/id_ed25519
  4. Add the SSH key to your account on GitHub. For more information, see “Adding a new SSH key to your GitHub account.”

Generate an ssh key on windows

Windows environments do not have a standard default unix shell. External shell programs will need to be installed for to have a complete keygen experience. The most straight forward option is to utilize Git Bash. Once Git Bash is installed the same steps for Linux and Mac can be followed within the Git Bash shell.

Похожее:  4. UserGate Getting Started. Работа с пользователями

How to create an ssh key

SSH keys are generated through a public key cryptographic algorithm, the most common being RSA or DSA. At a very high level SSH keys are generated through a mathematical formula that takes 2 prime numbers and a random seed variable to output the public and private key.

SSH keys are created using a key generation tool. The SSH command line tool suite includes a keygen tool. Most git hosting providers offer guides on how to create an SSH Key.

Prerequisites

To complete this tutorial, you will need:

Note: If you are looking for instructions on how to create SSH keys on a Windows machine that does not have the Windows Subsystem for Linux, please visit our product documentation How to Create SSH Keys with PuTTY on Windows.

Related topics/notes of interest:

  • Now that you know how to copy your ssh keys to a remote server and understand the process, you could use the command ssh-copy-id to achieve the same result, read the man page to learn more.

Summary

SSH keys are used to authenticate secure connections. Following this guide, you will be able to create and start using an SSH key. Git is capable of using SSH keys instead of traditional  password authentication when pushing or pulling to remote repositories. Modern hosted git solutions like Bitbucket support SSH key authentication.

The problem with passwords

Transmitting your password through the internet to connect to a remote server is dangerous. The password can be intercepted, or you can be tricked into sending it to a server pretending to be the real server. It doesn’t matter how but the problem is that the password is being transmitted and if intercepted it can be used by anyone to impersonate you.

It would be nice if you could establish a connection to a server and then prove that it is you by answering a series of questions that only you can answer. To make it harder, the questions change, and only you can answer those questions correctly. That is the idea behind using key pairs, let’s have a look.

Windows linux subsystem

Modern windows environments offer a windows linux subsystem. The windows linux subsystem offers a full linux shell within a traditional windows environment. If a linux subsystem is available the same steps previously discussed for Linux and Mac can be followed with in the windows linux subsystem.

Добавить комментарий

Ваш адрес email не будет опубликован. Обязательные поля помечены *