A SSH key is considered an access credential for the secure shell (SSH) network protocol. It is an encrypted and authenticated secure network protocol, applied for remote communication between machines operating on an unsecured network. This snippet will help you to find the kbd class="highlighted">SSH key on your PC if it exists, generate a new SSH key and learn how to add it to your ssh-agent or your GitHub/Bitbucket account.
You can do that by following the steps below. Type ls -al ~/.ssh so as to see your ssh keys:
ls -al ~/.ssh
By default, the filename of the public key is one of the following:
id_ecdsa.pub id_ed25519.pub id_rsa.pub
If you don't have an SSH key, you should create it. Now let’s generate a new SSH key step by step.
Type the command below, using your GitHub's account email:
ssh-keygen -t rsa -b 4096 -C "[your github's email]"
After running this command, you will be offered to set the SSH key path, but we recommend you to use its default value by pressing the "Enter" button.
> Enter a file in which to save the key (/Users/you/.ssh/id_rsa): [Press enter]
After that it will offer you to insert a passphrase to protect your SSH key.
> Enter passphrase (empty for no passphrase): [Type a passphrase] > Enter same passphrase again: [Type passphrase again]
Now, when you already have an SSH key, you can add it into the ssh-agent.
eval "$(ssh-agent -s)"
Open your terminal and type the command below:
Now, it will print the SSH key in the terminal, so you can copy it.
Now you have added your PC's SSH key to your GitHub's/Bitbucket's account.
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. 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.