<?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: Ian A. Drilon</title>
    <description>The latest articles on DEV Community by Ian A. Drilon (@zneret03).</description>
    <link>https://dev.to/zneret03</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%2F908164%2F63df0db0-c1c3-4af5-b2f2-81f004ee3a72.jpg</url>
      <title>DEV Community: Ian A. Drilon</title>
      <link>https://dev.to/zneret03</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/zneret03"/>
    <language>en</language>
    <item>
      <title>Unlocking Seamless Development: Mastering SSH Key Setup for Bitbucket and GitHub in WSL2</title>
      <dc:creator>Ian A. Drilon</dc:creator>
      <pubDate>Sat, 10 Jun 2023 12:29:25 +0000</pubDate>
      <link>https://dev.to/zneret03/how-to-create-ssh-and-connect-to-bitbucketgithub-in-wsl2-5cml</link>
      <guid>https://dev.to/zneret03/how-to-create-ssh-and-connect-to-bitbucketgithub-in-wsl2-5cml</guid>
      <description>&lt;h2&gt;
  
  
  Why use ssh?
&lt;/h2&gt;

&lt;p&gt;Using SSH as more secure option and HTTPS for basic, password-based Git usage. Since SSH is more secure than entering credentials over HTTPS, it is recommended for business dealing with sensitive and critical data. Once you generate you generate and connect your ssh key to your bitbucket/github, you can freely push and pull or make changes to your project repository&lt;/p&gt;

&lt;h3&gt;
  
  
  Why i'm doing this? 🤔🤔
&lt;/h3&gt;

&lt;p&gt;As your fellow developer, i was once struggling to setup my own SSH key to the version control that we are using in a company, by studying and discovering it on my own. I want to share how i setup my own SSH key and connect to the repository with no hassle.&lt;/p&gt;

&lt;h3&gt;
  
  
  Let's get into it 🔥
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Make sure &lt;code&gt;openssh-server&lt;/code&gt; is installed in your WSL Distro (In my own case i use Ubuntu.22.04 LTS)&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;

 &lt;span class="nx"&gt;sudo&lt;/span&gt; &lt;span class="nx"&gt;apt&lt;/span&gt; &lt;span class="nx"&gt;install&lt;/span&gt; &lt;span class="nx"&gt;openssh&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nx"&gt;client&lt;/span&gt;


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;ul&gt;
&lt;li&gt;Once the openssh-client installation is complete, in the terminal, check that openssh-client has been successfully installed by running the following command:&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;

&lt;span class="nx"&gt;ssh&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nx"&gt;V&lt;/span&gt;


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;the output will show the version of openssh you installed&lt;/p&gt;

&lt;h3&gt;
  
  
  Start the SSH agent
&lt;/h3&gt;

&lt;p&gt;To allow &lt;code&gt;git&lt;/code&gt; to use your SSH key, an SSH agent needs to be running in your machine. to do this, write this command in your terminal&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;

&lt;span class="nx"&gt;ps&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nx"&gt;a&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="nx"&gt;grep&lt;/span&gt; &lt;span class="nx"&gt;ssh&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nx"&gt;agent&lt;/span&gt;


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;to start the agent:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;

&lt;span class="nb"&gt;eval&lt;/span&gt; &lt;span class="nf"&gt;$&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;ssh&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nx"&gt;agent&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;you might need this to add in your &lt;code&gt;~/.bashrc&lt;/code&gt; so that if you restart your terminal it will automatically run in the background&lt;/p&gt;

&lt;h3&gt;
  
  
  Create an SSH key 🔑 pair (private/public)
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Open your terminal and navigate to your home by writing this command &lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;

&lt;span class="nx"&gt;cd&lt;/span&gt; &lt;span class="o"&gt;~&lt;/span&gt;


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;ul&gt;
&lt;li&gt;Generate your SSH key pair using ssh-keygen, write this command:&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;

&lt;span class="nx"&gt;ssh&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nx"&gt;keygen&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nx"&gt;t&lt;/span&gt; &lt;span class="nx"&gt;ed25519&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nx"&gt;b&lt;/span&gt; &lt;span class="mi"&gt;4096&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nx"&gt;C&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;username@emaildomain.com&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nx"&gt;f&lt;/span&gt; &lt;span class="nx"&gt;ssh&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nx"&gt;key&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;The &lt;strong&gt;&lt;a href="mailto:username@emaildomain.com"&gt;username@emaildomain.com&lt;/a&gt;&lt;/strong&gt; is the email you are using in bitbucket or github&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;the &lt;strong&gt;ssh-key-name&lt;/strong&gt; is the name of you ssh key example &lt;strong&gt;work-ssh&lt;/strong&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;After adding those command, the terminal will ask for you passphrase, &lt;strong&gt;you can either provide a phrase for a password&lt;/strong&gt; or leave it blank, if you input a password each time SSH is used, such as using git command that contact Bitbucket/Github (such as, pull and fetch). Providing password will prevent other users with access to the device from using your keys.&lt;/p&gt;

&lt;p&gt;Once you completed the command above, it will output two files such as &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;ssh-key-name&lt;/code&gt; - the &lt;em&gt;private key&lt;/em&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;ssh-key-name&lt;/code&gt;.pub - the &lt;em&gt;public key&lt;/em&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These files will be stored in your &lt;code&gt;home&lt;/code&gt; directory, the &lt;code&gt;ssh-key-name&lt;/code&gt;.pub that is the one we will be using to connect in bitbucket/github&lt;/p&gt;

&lt;h3&gt;
  
  
  Add your key 🔑 to the SSH agent
&lt;/h3&gt;

&lt;p&gt;We will now add our key to the ssh agent, write this command:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;

&lt;span class="nx"&gt;ssh&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nx"&gt;add&lt;/span&gt; &lt;span class="o"&gt;~&lt;/span&gt;&lt;span class="sr"&gt;/ssh-key-nam&lt;/span&gt;&lt;span class="err"&gt;e
&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Ater adding our ssh key to ssh agent, we will now be able to add our ssh public key to the bitbucket/github&lt;/p&gt;

&lt;h3&gt;
  
  
  Provide Bitbucket Cloud with your public key 🔑
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;At bitbucket, select your avatar (Your profile and settings) from the upper right screen of your monitor&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Under &lt;strong&gt;Settings&lt;/strong&gt;, Select &lt;strong&gt;Personal Settings&lt;/strong&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Under &lt;strong&gt;Security&lt;/strong&gt; tab, select &lt;strong&gt;SSH key&lt;/strong&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;in the &lt;strong&gt;Add SSH Key&lt;/strong&gt; it will prompt you a dialog box, where in you can add your ssh key example: &lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;

&lt;span class="nx"&gt;ssh&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nx"&gt;ed25529&lt;/span&gt; &lt;span class="nx"&gt;LLoWYaPswHzVqQ7L7B07LzIJbntgmHqrE40t17nGXL71QX9IoFGKYoF5pJKUMvR&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="nx"&gt;DZotTm&lt;/span&gt; &lt;span class="nx"&gt;user&lt;/span&gt;&lt;span class="p"&gt;@&lt;/span&gt;&lt;span class="nd"&gt;example&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;com&lt;/span&gt;


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;you will find this key inside of your &lt;code&gt;ssh-key-name&lt;/code&gt;.pub file just copy and paste, don't forget your label. For example &lt;code&gt;Work Machine&lt;/code&gt;. this will help you identify old or unwanted keys in the future.&lt;/p&gt;

&lt;p&gt;after adding your ssh public key, if you received an error that &lt;code&gt;SSH key is invalid&lt;/code&gt;, double check that you copied the entire contents of the public key (&lt;code&gt;.pub&lt;/code&gt; file)&lt;/p&gt;

&lt;h3&gt;
  
  
  Check that your SSH authentication works
&lt;/h3&gt;

&lt;p&gt;To test your ssh key if successfully, open a terminal on your machine and add this command&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;

&lt;span class="nx"&gt;ssh&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nx"&gt;T&lt;/span&gt; &lt;span class="nx"&gt;git&lt;/span&gt;&lt;span class="p"&gt;@&lt;/span&gt;&lt;span class="nd"&gt;bitbucket&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;org&lt;/span&gt;


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;if SSH can successfully connect with Bitbucket using your SSH keys, the command will produce output similar to &lt;/p&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;

&lt;p&gt;&lt;span class="nx"&gt;authenticated&lt;/span&gt; &lt;span class="nx"&gt;via&lt;/span&gt; &lt;span class="nx"&gt;ssh&lt;/span&gt; &lt;span class="nx"&gt;key&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;/p&gt;

&lt;p&gt;&lt;span class="nx"&gt;You&lt;/span&gt; &lt;span class="nx"&gt;can&lt;/span&gt; &lt;span class="nx"&gt;use&lt;/span&gt; &lt;span class="nx"&gt;git&lt;/span&gt; &lt;span class="nx"&gt;to&lt;/span&gt; &lt;span class="nx"&gt;connect&lt;/span&gt; &lt;span class="nx"&gt;to&lt;/span&gt; &lt;span class="nx"&gt;Bitbucket&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt; &lt;span class="nx"&gt;Shell&lt;/span&gt; &lt;span class="nx"&gt;access&lt;/span&gt; &lt;span class="nx"&gt;is&lt;/span&gt; &lt;span class="nx"&gt;disabled&lt;/span&gt;&lt;/p&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h3&gt;
&lt;br&gt;
  &lt;br&gt;
  &lt;br&gt;
  Provide Github with your public key 🔑&lt;br&gt;
&lt;/h3&gt;

&lt;p&gt;Adding SSH key in your github is more simple than you expected&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Copy your SSH public key in your &lt;code&gt;.pub&lt;/code&gt; file&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;In the upper right corner in your github profile you can click your avatar, and click the &lt;strong&gt;Settings&lt;/strong&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxbw61wma9f6l8mxq1wjd.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxbw61wma9f6l8mxq1wjd.png" alt="github settings"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;In the &lt;strong&gt;SSH and GPG keys&lt;/strong&gt; Click the &lt;strong&gt;New SSH key&lt;/strong&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;it will redirect you to the page like this&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6ivqi066nwxwlxe7ctce.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6ivqi066nwxwlxe7ctce.png" alt="SSH key and GPG keys"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Similar to the bitbucket we mentioned earlier, add your public key to the &lt;strong&gt;key&lt;/strong&gt; section and some descriptive title that will help your determine the old and new keys in the future&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Select the type of key, either authentication or signing. For more information about commit signing you can refer to this link &lt;a href="https://docs.github.com/en/authentication/managing-commit-signature-verification/about-commit-signature-verification" rel="noopener noreferrer"&gt;here&lt;/a&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;after adding all the necessary information, click the &lt;strong&gt;add SSH key&lt;/strong&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;If everything went well, github will send you the confirmation access directly to your account. For more information, see &lt;a href="https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/sudo-mode" rel="noopener noreferrer"&gt;Sudo mode&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Congratulations 👏👏👏
&lt;/h3&gt;

&lt;p&gt;Congratulations on adding your first SSH key to your favorite or chosen version control system. By this blog post, i hope we can help more developers who are struggling on setting up their first SSH keys on your side projects, side hustles or company project. &lt;/p&gt;

</description>
      <category>ubuntu</category>
      <category>bash</category>
      <category>cli</category>
    </item>
  </channel>
</rss>
