<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Hubert Nare</title>
    <description>The latest articles on DEV Community by Hubert Nare (@hubertnare).</description>
    <link>https://dev.to/hubertnare</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F492151%2F7fd1f760-7c34-4764-9ba8-36ccafb50928.jpg</url>
      <title>DEV Community: Hubert Nare</title>
      <link>https://dev.to/hubertnare</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/hubertnare"/>
    <language>en</language>
    <item>
      <title>How to "SSH!🤫" into your GitHub account.</title>
      <dc:creator>Hubert Nare</dc:creator>
      <pubDate>Wed, 17 Nov 2021 14:43:43 +0000</pubDate>
      <link>https://dev.to/hubertnare/setting-up-github-authentication-using-ssh-21ac</link>
      <guid>https://dev.to/hubertnare/setting-up-github-authentication-using-ssh-21ac</guid>
      <description>&lt;h2&gt;
  
  
  Agenda
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Introduction&lt;/li&gt;
&lt;li&gt;What are SSH Keys?&lt;/li&gt;
&lt;li&gt;Generating SSH keys&lt;/li&gt;
&lt;li&gt;Passing a public SSH key to GitHub&lt;/li&gt;
&lt;li&gt;Testing SSH connection&lt;/li&gt;
&lt;li&gt;Conclusion&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Introduction.
&lt;/h2&gt;

&lt;p&gt;Doesn't it get boring that each time you have to identify yourself to GitHub you must provide your username and password? Well mate, you don't have to go through all the hustle of using password authentication just to identify yourself. In this article, you'll learn an alternate password-less way to identify yourself. No need to use your username and password every time. Follow along with this article to get how it's done.&lt;/p&gt;

&lt;p&gt;The article is focused on teaching you how to use an alternate way of authenticating to GitHub using SSH keys. &lt;/p&gt;

&lt;h3&gt;
  
  
  What are SSH keys?
&lt;/h3&gt;

&lt;p&gt;To understand what SSH Keys are, first, you have to know a Secure Shell or SSH for short. Simply put, SSH is basically a secure way of communication used between two nodes (client and host). SSH is a secure communication protocol used in a communication link. In this context, GitHub is the host and your PC the client.&lt;/p&gt;

&lt;p&gt;Your PC (client) and GitHub (host) will use this secure SSH protocol in their communication link to securely authenticate you without the use of a password.&lt;/p&gt;

&lt;p&gt;But, the question remains, what are &lt;strong&gt;SSH Keys&lt;/strong&gt;?&lt;/p&gt;

&lt;p&gt;Like shoes, SSH keys come in pairs consisting of one public and private key, forming a public-private SSH key pair. SSH keys play a vital role in maintaining security in SSH protocols. The SSH protocol uses asymmetric encryption as its security basis. SSH keys are then used in the protocol separately for encryption and decryption.&lt;/p&gt;

&lt;p&gt;Okay then, enough of the chit-chat. It's time you create your own pair of SSH keys.&lt;/p&gt;

&lt;h3&gt;
  
  
  Generating SSH keys;
&lt;/h3&gt;

&lt;p&gt;Copy and paste the command below in your terminal to generate a new SSH key pair;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ssh-keygen -t rsa -b 4096 -C 'Your_Email_Address'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Press enter, you will see a prompt to enter a "passphrase".&lt;/li&gt;
&lt;li&gt;A passphrase is not mandatory. However, it is recommended that you specify a passphrase to protect your private key against unauthorized use (press enter to skip this for now).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Congrats, the command above generated an SSH key pair for you and saved it in a specific path. This key is of &lt;code&gt;rsa&lt;/code&gt; type.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Note;&lt;br&gt;
&lt;code&gt;-t&lt;/code&gt; refers to SSH key type (in this case we're using the &lt;code&gt;rsa&lt;/code&gt; SSH key type).&lt;br&gt;
&lt;code&gt;-b&lt;/code&gt; refers to size of SSH key in bits. The minimum bit length is 768 bits and the default length is 2048 bits. So in the command above you're setting the SSH key to a size of 4096 bits.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  Passing a public SSH key to GitHub;
&lt;/h3&gt;

&lt;p&gt;From your pair of SSH keys, GitHub should have one key. You are going to give it the public key instead. The other key, the private one, you are going to keep it in a program called ssh-agent.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"The ssh-agent is a helper program that keeps track of users’ identity keys and their passphrases. The agent can then use the keys to log into other servers without having the user type in a password or passphrase again. This implements a form of single sign-on (SSO)."  &lt;a href="https://www.ssh.com/academy/ssh/agent"&gt;read more from SSH Academy&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Paste the command below to start the ssh-agent;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;eval `ssh-agent -s`
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Done?&lt;/p&gt;

&lt;p&gt;Okay now you can go on to adding that private SSH key to ssh-agent using the command below;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ssh-add ~/.ssh/id_rsa
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Awesome!&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Note;&lt;br&gt;
The public rsa SSH key filename &lt;code&gt;id_rsa.pub&lt;/code&gt; has a &lt;code&gt;.pub&lt;/code&gt; extension and the private has no extension.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Remember, you are supposed to give GitHub your public key. Copy the public SSH key to clipboard by running the command below;&lt;/p&gt;

&lt;p&gt;Mac;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;pbcopy &amp;lt; ~/.ssh/id_rsa.pub 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Windows;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;clip &amp;lt; ~/.ssh/id_rsa.pub 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now you have to paste the key to your &lt;a href=""&gt;GitHub&lt;/a&gt; account. Sign in to your account and follow the steps below to add a key.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 1 - Settings;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Once you sign in to your GitHub, click on your account avatar, found at the top right corner of your screen. A dropdown will show. &lt;/p&gt;

&lt;p&gt;Now, click on &lt;strong&gt;Settings&lt;/strong&gt; from that dropdown menu.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--SCbDKBWV--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/eyqcanlafceg5k3ee9xw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--SCbDKBWV--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/eyqcanlafceg5k3ee9xw.png" alt="github settings" width="880" height="541"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 2 - SSH and GPG keys.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In &lt;strong&gt;Settings&lt;/strong&gt;, there is a menu at your left. Click on &lt;strong&gt;SSH and GPG keys&lt;/strong&gt; tab from that left menu. You will see a page like below;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--VdmjI6hW--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ospohav2118xbu573v64.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--VdmjI6hW--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ospohav2118xbu573v64.png" alt="ssh and gpg keys" width="880" height="541"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;On this page, click the button &lt;strong&gt;New SSH Key&lt;/strong&gt;. The button will redirect you to a page where you are going to add your public SSH key.&lt;/p&gt;

&lt;p&gt;Head over to the following step to do that.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 3 - paste public SSH key.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Now, its time you give that public key to GitHub.&lt;/p&gt;

&lt;p&gt;Here is what you have to do;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;There is a textbox for a title. Enter SSH key title of your own choice.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Paste in the public SSH key you copied to clipboard from your terminal.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Finally, click on &lt;strong&gt;Add SSH key&lt;/strong&gt; button.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--6quwJLRy--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/m7mba0saapi9xl7j81z5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--6quwJLRy--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/m7mba0saapi9xl7j81z5.png" alt="public ssh keys" width="880" height="530"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 4 - confirm&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;GitHub will ask for your password as confirmation. Type in your password to proceed.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--6HUl287U--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/oaxqctwiml505ys2y5l8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--6HUl287U--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/oaxqctwiml505ys2y5l8.png" alt="confirm password" width="880" height="639"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Done?&lt;/p&gt;

&lt;p&gt;You will see your public key added on to a list of SSH keys on the &lt;strong&gt;SSH and GPG keys&lt;/strong&gt; page like below;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--gpxkExcZ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bt7osi1j67mftsyjfgon.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--gpxkExcZ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bt7osi1j67mftsyjfgon.png" alt="list of public ssh keys" width="880" height="541"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  Wrapping up!
&lt;/h3&gt;

&lt;p&gt;Run this last command below you to test for connection.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ssh -T git@github.com
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You should get results similar to that below;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--U6lPKrNX--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/puf1g0shznwllmupq3zv.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--U6lPKrNX--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/puf1g0shznwllmupq3zv.png" alt="ssh terminal response" width="880" height="642"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Nicely done!&lt;/p&gt;

&lt;p&gt;Now let's take our new SSH keys for a test drive, shall we?&lt;/p&gt;

&lt;p&gt;Head over to this GitHub &lt;a href=""&gt;repo&lt;/a&gt; and copy the SSH link of the repo to your clipboard.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--F-5iIxtV--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mw96emj4j4irzm91mqih.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--F-5iIxtV--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mw96emj4j4irzm91mqih.png" alt="github repo" width="880" height="541"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now in your terminal, type the command;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git clone "paste_in_the_copied_SSH_repo_link_without_qoutes"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;and press enter. The code above will clone that repo using SSH connection.&lt;/p&gt;

&lt;p&gt;And that my friend is one use case of GitHub SSH keys.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Conclusion;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Great job! You have successfully added a new SSH key to your Github profile. For further reading, I recommend this &lt;a href=""&gt;article&lt;/a&gt; which is a deep-dive on SSH. If you have any questions feel free to ping me.&lt;/p&gt;

&lt;p&gt;Till we meet again mate.&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>github</category>
      <category>opensource</category>
      <category>tutorial</category>
    </item>
  </channel>
</rss>
