SSH keys are an access credential used in SSH protocol (Secure Shell) which is a network protocol that helps to login from one computer to another securely, as well as to manage networks, operating systems, and configurations. This snippet is going to help you add an SSH key to the ssh-agent, generate a new SSH key, learn how to find the SSH key of your PC and how to connect it with your GitHub/bitbucket account. You can also find information on the use of SSH keys.
Now let's find out how we can checkout PC's SSH keys.
![Gui Gui](/uploads/1/2/6/8/126896254/144409251.png)
Set up SSH key authentication Step 1: Create your SSH keys. Step 2: Add the public key to Azure DevOps Services/TFS. Step 3: Clone the Git repository with SSH. Creating your SSH key pair; Adding your SSH public key to GitLab. Create and add your SSH key pair. It is best practice to use Git over SSH instead of Git over HTTP. In order to use SSH, you will need to: Create an SSH key pair; Add your SSH public key to GitLab. Creating your SSH key pair. Go to your command line. Jul 20, 2018 Generating a new key You generate a new SSH key using the command ssh-keygen, which is available on all macOS, Linux and modern Windows computers with the Linux subsystem or the Git for Windows package. Here’s the command you use: ssh-keygen -t rsa -b 4096 -C '[email protected]'.
Checking PC's SSH Keys
Type ls -al ~/.ssh so as to see your ssh keys:
By default, the filenames of the public keys are one of the following:
Generate a new SSH key
Type this below, using your GitHub's account email:
The following text will show up after which you can hit the “Enter” button:
In this section, you can hit “Enter” again or type the secure passphrase (more about passphrase).
Adding an SSH key to the ssh-agent
Now let’s find out how we can add the SSH key to ssh-agent. Before adding, check your ssh keys or generate a new key.
- Be sure ssh-agent is enabled:
- Add your SSH key to the ssh-agent. If you used an existing SSH key rather than generating a new SSH key, you would need to replace id_rsa in the command with the name of your existing private key file:
How To Add SSH Key To Github Account
- Log into your Github's account. In the top right corner of any page, click your profile photo, then click Settings.
- In the user settings sidebar, go to SSH and GPG keys.
- Click New SSH key.
- Type Title and your SSH Key.
You can get your ssh key by typing below.
Now you have added your PC's SSH key to your Github's account.
Back up old SSH keys
![Git Gui Generate New Ssh Key Git Gui Generate New Ssh Key](/uploads/1/2/6/8/126896254/551021497.png)
Ssh Generate Key
If there are existing SSH keys, but you do not want to use them for connecting to Bitbucket Server, you should back up these old keys running the following:
Why we need SSH key (for Linux and OSX)
If you use Git and want to clone anything from remote repositories, you have to choose one of these two ways: HTTPS or SSH. If you use HTTPS, you have to type your account access every time you communicate with the remote repository, or change your configs and fill your account data (access). Another modern way is to use the SSH authentication method. It is used in many Version Control Systems to have command line access into your servers, etc. SSH key pairs can be used for authentication instead of passwords. Each key pair consists of a private key and a corresponding public key. When you use SSH key for Git, you inform Git that this PC is authenticated for that Github account, and it will never ask you about any access again because you have already given it your SSH key.
Related Resources ¶
Thanks for your feedback!
Related articles
macos_sierra_chorke_ssh.sh
Generate Ssh Key Git Bash
# generating a new ssh key and adding it to the ssh agent |
# https://help.github.com/articles/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent/ |
# ssh key generation for chorke |
ssh-keygen -t rsa -b 4096 -C '[email protected]' |
# Generating public/private rsa key pair. |
# Enter a file in which to save the key (/Users/you/.ssh/id_rsa): [Press enter] |
# Enter passphrase (empty for no passphrase): [Type a passphrase] |
# Enter same passphrase again: [Type passphrase again] |
# start or check ssh-agent |
eval'$(ssh-agent -s)' |
# Agent pid 2911 |
# bit_chorke_rsa add to ~/.ssh/config |
# Host bit.chorke.com |
# HostName bitbucket.org |
# PreferredAuthentications publickey |
# IdentityFile ~/.ssh/bit_chorke_rsa |
# User git |
# git_chorke_rsa add to ~/.ssh/config |
# Host git.chorke.com |
# HostName github.com |
# PreferredAuthentications publickey |
# IdentityFile ~/.ssh/git_chorke_rsa |
# User git |
# add key to ssh-agent |
ssh-add -K ~/.ssh/id_rsa |
ssh-add -K ~/.ssh/bit_chorke_rsa |
ssh-add -K ~/.ssh/git_chorke_rsa |
Create Ssh Key For Git
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment