The entire Pro Git book, written by Scott Chacon and Ben Straub and published by Apress, is available here. All content is licensed under the Creative Commons Attribution Non Commercial Share Alike 3.0 license. That being said, many Git servers authenticate using SSH public keys. In order to provide a public key, each user in your system must generate one if they don’t already have one. This process is similar across all operating systems. First, you should check to make sure you don’t already have a key. Many Git servers authenticate using SSH public keys. In order to provide a public key, each user in your system must generate one if they don’t already have one. This process is similar across all operating systems. First, you should check to make sure you don’t already have a key.
You can add SSH key to Git using the following commands −
Step 1 − Open Git Bash and get the ssh-agent using the following command.
Step 2 − Next, add the SSH key to the ssh-agent using the following command
Step 3 − Now, run the ssh using the following command, which matches the SSH fingerprint used when logging for the first time.
In the above screenshot, you can see that xyz123 is a instance shell account name, which is used while creating Gerrit account and Abc123 is a user name of your Gerrit account.
SSH keys are a way to identify trusted computers, without involving passwords. The steps below will walk you through generating an SSH key and adding the public key to the server.
First, check for existing SSH keys on your computer. Open Git Bash, Cygwin, or Terminal, etc. and enter:
Check the directory listing to see if you already have a public SSH key. By default, the filenames of the public keys are one of the following:
If you see an existing public and private key pair listed (for example id_rsa.pub and id_rsa) that you’d like to use, you can skip Step 2 and go straight to Step 3.
With your command line tool still open, enter the text shown below. Make sure you substitute in your email address:
You’ll be asked to enter a passphrase, or simply press Enter to not enter a passphrase:
After you enter a passphrase (or just press Enter twice), review the fingerprint, or ‘id’ of your SSH key:
To configure the ssh-agent program to use your SSH key, first ensure ssh-agent is enabled.
If you are using Git Bash, turn on the ssh-agent with command shown below instead:
Then, add your SSH key to the ssh-agent:
To add your public SSH key to the server, you’ll copy the public SSH key you just created to the server. Substitute “username” with your username on the server, and “server.address.com” with the domain address or IP address of your server:
https://ameblo.jp/specemeson1970/entry-12632595165.html. The server will then prompt you for your password:
That’s it! You should now be set up to connect to the server without having to authenticate.