<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>ssh-keys Archives | The Curious Technoid</title>
	<atom:link href="https://thecurioustechnoid.com/tag/ssh-keys/feed/" rel="self" type="application/rss+xml" />
	<link>https://thecurioustechnoid.com/tag/ssh-keys/</link>
	<description>technology made simple</description>
	<lastBuildDate>Tue, 07 Jul 2020 18:22:18 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.5</generator>

<image>
	<url>https://thecurioustechnoid.com/wp-content/uploads/2020/06/cropped-fav-1-32x32.png</url>
	<title>ssh-keys Archives | The Curious Technoid</title>
	<link>https://thecurioustechnoid.com/tag/ssh-keys/</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>How to use SSH Keys</title>
		<link>https://thecurioustechnoid.com/how-to-setup-ssh-keys/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=how-to-setup-ssh-keys</link>
					<comments>https://thecurioustechnoid.com/how-to-setup-ssh-keys/#respond</comments>
		
		<dc:creator><![CDATA[Rakshith Chengappa Mullengada]]></dc:creator>
		<pubDate>Wed, 17 Jun 2020 14:06:40 +0000</pubDate>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[ssh]]></category>
		<category><![CDATA[ssh keys]]></category>
		<category><![CDATA[ssh-keys]]></category>
		<guid isPermaLink="false">https://thecurioustechnoid.com/?p=208</guid>

					<description><![CDATA[<p>SSH Keys are one of the safest ways to connect to your server. It involves public-private key pair which authenticates the user to login to the server. The private key is installed in the local Desktop / Server, whereas the public key in installed in the server to which you wish to connect. Today we&#8230;</p>
<p>The post <a href="https://thecurioustechnoid.com/how-to-setup-ssh-keys/">How to use SSH Keys</a> appeared first on <a href="https://thecurioustechnoid.com">The Curious Technoid</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>SSH Keys are one of the safest ways to connect to your server. It involves public-private key pair which authenticates the user to login to the server. The <em><strong>private key</strong></em> is installed in the local Desktop / Server, whereas the <em><strong>public key</strong></em> in installed in the server to which you wish to connect.</p>



<div class="wp-block-image"><figure class="aligncenter size-large is-resized"><a href="https://youtu.be/Dj3vz0VtuvY" target="_blank" rel="noopener noreferrer"><img decoding="async" src="https://thecurioustechnoid.com/wp-content/uploads/2020/06/WatchOnYoutubeImage.png" alt="" class="wp-image-78" width="217" height="87"/></a></figure></div>



<p>Today we will cover the below topics which will help you start using SSH keys right away:</p>



<ul class="wp-block-list"><li>Generation of SSH Keys</li><li>Installation of SSH Keys</li><li>Connecting using SSH Keys</li><li>SSH Config File</li></ul>



<div style="height:25px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading">How to generate SSH Keys</h3>



<p>We can generate the SSH Key pair using the <strong>ssh-keygen</strong> command. You have the option to choose from 4 encryption algorithms that <strong>ssh-keygen</strong> supports as of this writing. The 4 algorithms are rsa, dsa , ecdsa and ed25519. I always use <em>ecdsa</em> which is a strong algorithm that meets modern security standards. It is highly recommended you generate the SSH key pair using a passphrase. This ensures that, if someone gets their hand on your private key, they wouldn&#8217;t be able to use it without the passphrase.</p>



<p>In your local Desktop / Server you can generate SSH Key pair using the below command:</p>



<pre class="wp-block-code"><code>ssh-keygen -t ecdsa</code></pre>



<p>When you the above command is executed, you will be prompted with the below (optional) inputs:</p>



<ul class="wp-block-list"><li><strong>Enter file in which to save the key (/root/.ssh/id_ecdsa):</strong> &#8211; If you don&#8217;t pass any value to this, the key-pair will be created in the <code>~/.ssh</code> folder by default, with the name <em>id_ecdsa</em>. You can always enter your preferred name to override this.</li><li><strong>Enter passphrase (empty for no passphrase):</strong> &#8211; This accept empty sting as input if you don&#8217;t wish to use a passphrase. However, I strongly recommend you provide a passphrase so that no-one else will be able to access your private key.</li></ul>



<figure class="wp-block-image size-large"><img fetchpriority="high" decoding="async" width="974" height="636" src="https://thecurioustechnoid.com/wp-content/uploads/2020/06/ssh-generation1.png" alt="" class="wp-image-214" srcset="https://thecurioustechnoid.com/wp-content/uploads/2020/06/ssh-generation1.png 974w, https://thecurioustechnoid.com/wp-content/uploads/2020/06/ssh-generation1-768x501.png 768w" sizes="(max-width: 974px) 100vw, 974px" /><figcaption><em><strong>-t ecdsa </strong>option would use the ecdsa algorithm to create the key file pair</em></figcaption></figure>



<p>Once the keys are generated, you will find two files created by <strong>ssh-keygen</strong>, in my case they are: <strong>id_curioustechnoid</strong> and <strong>id_curioustechnoid.pub</strong></p>



<figure class="wp-block-image size-large"><img decoding="async" width="864" height="354" src="https://thecurioustechnoid.com/wp-content/uploads/2020/06/ssh-keys.png" alt="" class="wp-image-212" srcset="https://thecurioustechnoid.com/wp-content/uploads/2020/06/ssh-keys.png 864w, https://thecurioustechnoid.com/wp-content/uploads/2020/06/ssh-keys-768x315.png 768w" sizes="(max-width: 864px) 100vw, 864px" /></figure>



<p><strong>id_curioustechnoid </strong>         : This is your private key<br><strong>id_curioustechnoid.pub </strong>: This is your public key which we need to install in the remote server</p>



<div style="height:25px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading">How to install SSH Keys</h3>



<p>Now that the SSH Keys are generated, let&#8217;s go ahead and install them.</p>



<h5 class="wp-block-heading">1. Install the private key in your local Desktop / Server</h5>



<p>Installation of your private key in your local Desktop / Server is pretty straightforward and easy. You just copy your private key to <code>~/.ssh</code> directory (if your key is not already there):</p>



<p>First create the <code>~/.ssh </code>directory <em>if it doesn&#8217;t exist</em>:</p>



<pre class="wp-block-code"><code>mkdir ~/.ssh
chmod 700 ~/.ssh</code></pre>



<p>Followed by moving the private key to that directory</p>



<pre class="wp-block-code"><code>mv id_curioustechnoid ~/.ssh</code></pre>



<figure class="wp-block-image size-large is-style-default"><img loading="lazy" decoding="async" width="760" height="496" src="https://thecurioustechnoid.com/wp-content/uploads/2020/06/ssh-privatekey-install1.png" alt="" class="wp-image-221"/><figcaption>Make sure ~/.ssh folder permission is 700</figcaption></figure>



<p>That&#8217;s it! The private key is now installed in your local Desktop or Server.</p>



<p>You can keep your private key in any directory that you want, it&#8217;s a good practice to keep them in <code>~/.ssh</code> folder in your home directory. If you run the <strong>ssh-keygen</strong> command using all default values, your public-private key pair will be created in <code>~/.ssh</code> directory.</p>



<h5 class="wp-block-heading">2. Install the public key in the remote server</h5>



<p>Let&#8217;s see how we can install the public key in the remote server to which you wish to connect.</p>



<p>Firstly, transfer the public key that you created to your server using your favourite <em>sftp</em> tool. Since I am connected to a headless demo server without GUI I will use the good old <code>scp</code> command for this purpose. I will be transferring the key to my <em>development.local</em> server to which I will be connecting to.</p>



<pre class="wp-block-verse"><code>scp id_curioustechnoid.pub guest@development.local:~/</code></pre>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1009" height="304" src="https://thecurioustechnoid.com/wp-content/uploads/2020/06/ssh-scp.png" alt="" class="wp-image-216" srcset="https://thecurioustechnoid.com/wp-content/uploads/2020/06/ssh-scp.png 1009w, https://thecurioustechnoid.com/wp-content/uploads/2020/06/ssh-scp-768x231.png 768w" sizes="auto, (max-width: 1009px) 100vw, 1009px" /></figure>



<p>What this will do is copy the public key that we just created to my development server and place the file in the home directory.</p>



<p>Next we login to the development server using our username/password: </p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="806" height="122" src="https://thecurioustechnoid.com/wp-content/uploads/2020/06/ssh-connect-dev.png" alt="" class="wp-image-219" srcset="https://thecurioustechnoid.com/wp-content/uploads/2020/06/ssh-connect-dev.png 806w, https://thecurioustechnoid.com/wp-content/uploads/2020/06/ssh-connect-dev-768x116.png 768w" sizes="auto, (max-width: 806px) 100vw, 806px" /><figcaption>Connecting using SSH</figcaption></figure>



<p>After logging in, append your public key to the SSH authorization file: <code>~/.ssh/authorized_keys</code></p>



<pre class="wp-block-verse"><code>cat id_curioustechnoid.pub &gt;&gt; ~/.ssh/authorized_keys</code></pre>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="891" height="555" src="https://thecurioustechnoid.com/wp-content/uploads/2020/06/ssh-publickey-install1.png" alt="" class="wp-image-220" srcset="https://thecurioustechnoid.com/wp-content/uploads/2020/06/ssh-publickey-install1.png 891w, https://thecurioustechnoid.com/wp-content/uploads/2020/06/ssh-publickey-install1-768x478.png 768w" sizes="auto, (max-width: 891px) 100vw, 891px" /><figcaption>Make sure the directory ~/.ssh has 700 permission and file: ~/.ssh/authorized_keys has 600 permission</figcaption></figure>



<p>Don&#8217;t forget to remove the public key file from home directory by running: <code>rm ~/id_curioustechnoid.pub</code></p>



<p>There you have it, public key successfully installed in the server.</p>



<div style="height:25px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading">How to connect using SSH Keys</h3>



<p>The above steps ensures that the SSH setup is in place, now we can go ahead and connect to our server using the SSH Keys. The below option(-i) tells SSH to use the private key that we just created to connect to <em>development.local</em> server:</p>



<pre class="wp-block-code"><code>ssh guest@development.local -i ~/.ssh/id_curioustechnoid</code></pre>



<p>You will be prompted to enter the passphrase on the screen. Soon after we do, we should be able to successfully connect to the development server.</p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1018" height="376" src="https://thecurioustechnoid.com/wp-content/uploads/2020/06/ssh-key-connection.png" alt="" class="wp-image-223" srcset="https://thecurioustechnoid.com/wp-content/uploads/2020/06/ssh-key-connection.png 1018w, https://thecurioustechnoid.com/wp-content/uploads/2020/06/ssh-key-connection-768x284.png 768w" sizes="auto, (max-width: 1018px) 100vw, 1018px" /></figure>



<div style="height:25px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading">SSH config file</h3>



<p>If you connect to multiple servers like me, managing the keys becomes cumbersome and hard to remember. That&#8217;s where SSH config file comes in handy. It&#8217;s a master configuration file where you can list all your SSH connections and it&#8217;s respective keys. This makes accessing any server more convenient.</p>



<p>Let&#8217;s go ahead and create a config file and enter the details of our development server:</p>



<h5 class="wp-block-heading">1. SSH by default recognizes the config file under ~/.ssh directory. </h5>



<p>Let us create the SSH config file using the below command and give it the correct permission(600): </p>



<pre class="wp-block-code"><code>touch ~/.ssh/config
chmod 600 ~/.ssh/config</code></pre>



<h5 class="wp-block-heading">2. Enter your SSH details in the below format</h5>



<p>Open the file <code>~/.ssh/config</code> using your <a href="https://thecurioustechnoid.com/category/vim/" target="_blank" rel="noreferrer noopener">favorite editor</a>:</p>



<pre class="wp-block-code"><code>Host dev
    HostName development.local
    User guest
    IdentityFile ~/.ssh/id_curioustechnoid


Host other-server
    HostName 192.168.1.232
    User root
    IdentityFile ~/.ssh/id_ecdsa</code></pre>



<p>You can keep adding any number of server details in this file. Once the server details are added, connecting to the server is a breeze:</p>



<pre class="wp-block-code"><code>ssh dev</code></pre>



<p>This will prompt you for the passphrase. You enter the passphrase and you will be logged into the development server. Pretty handy isn&#8217;t it.</p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="899" height="304" src="https://thecurioustechnoid.com/wp-content/uploads/2020/06/ssh-config-connect.png" alt="" class="wp-image-224" srcset="https://thecurioustechnoid.com/wp-content/uploads/2020/06/ssh-config-connect.png 899w, https://thecurioustechnoid.com/wp-content/uploads/2020/06/ssh-config-connect-768x260.png 768w" sizes="auto, (max-width: 899px) 100vw, 899px" /></figure>



<p> </p>



<p>There you go, we just created, configured and installed SSH keys.</p>



<figure class="wp-block-embed-youtube aligncenter wp-block-embed is-type-video is-provider-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio"><div class="wp-block-embed__wrapper">
<iframe loading="lazy" title="How to use SSH Keys" width="640" height="360" src="https://www.youtube.com/embed/Dj3vz0VtuvY?feature=oembed" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe>
</div></figure>
<p>The post <a href="https://thecurioustechnoid.com/how-to-setup-ssh-keys/">How to use SSH Keys</a> appeared first on <a href="https://thecurioustechnoid.com">The Curious Technoid</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://thecurioustechnoid.com/how-to-setup-ssh-keys/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>

<!--
Performance optimized by W3 Total Cache. Learn more: https://www.boldgrid.com/w3-total-cache/

Page Caching using Disk: Enhanced 
Database Caching 3/40 queries in 0.006 seconds using Disk

Served from: thecurioustechnoid.com @ 2026-07-30 03:15:58 by W3 Total Cache
-->