<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
<channel>
<title>Coder Legion - Recent posts tagged setup</title>
<link>https://coderlegion.com/tag/setup</link>
<description>Powered by Question2Answer</description>
<item>
<title>How does SSH work and how can it be set up?</title>
<link>https://coderlegion.com/16119/how-does-ssh-work-and-how-can-it-be-set-up</link>
<description>
&lt;p&gt;Hello, I'm Ganesh. I'm building &lt;em&gt;git-lrc&lt;/em&gt;, an AI code reviewer that runs on every commit. It is free, unlimited, and source-available on Github. &lt;a href=&quot;https://github.com/HexmosTech/git-lrc&quot; rel=&quot;noopener noreferrer nofollow&quot;&gt;Star Us&lt;/a&gt; to help devs discover the project. Do give it a try and share your feedback for improving the product.&lt;/p&gt;

&lt;p&gt;Secure Shell (SSH) is a cryptographic network protocol that allows you to operate network services securely over an unsecured network.&lt;/p&gt;

&lt;p&gt;It is most commonly used for logging into a remote terminal and executing commands.&lt;/p&gt;

&lt;h2&gt;
  
  
  How SSH Works
&lt;/h2&gt;

&lt;p&gt;SSH uses a &lt;strong&gt;client-server model&lt;/strong&gt; and relies on a suite of encryption technologies to ensure that data remains confidential and untampered.&lt;/p&gt;

&lt;h3&gt;
  
  
  1. The Handshake
&lt;/h3&gt;

&lt;p&gt;When we connect to a server, the two machines exchange supported encryption protocols and settle on a mutually compatible version. &lt;/p&gt;

&lt;p&gt;They also establish a session key using a process like the Diffie-Hellman algorithm, which allows them to create a shared secret without actually sending the key across the network.&lt;/p&gt;

&lt;p&gt;Here is the video explaining this process:&lt;br&gt;
&lt;a href=&quot;https://youtu.be/aoag03mSuXQ?t=729&quot; rel=&quot;noopener noreferrer nofollow&quot;&gt;Link&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  2. Authentication
&lt;/h3&gt;

&lt;p&gt;Once the encrypted channel is established, the server needs to verify who you are. This usually happens in one of two ways:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Password Authentication:&lt;/strong&gt; You send your password through the encrypted tunnel.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Key-based Authentication:&lt;/strong&gt; The most secure method, using a &lt;strong&gt;Public Key&lt;/strong&gt; (stored on the server) and a &lt;strong&gt;Private Key&lt;/strong&gt; (stored on your machine).&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;
  
  
  3. Encryption Layers
&lt;/h3&gt;

&lt;p&gt;SSH utilizes three different types of encryption:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Symmetrical Encryption:&lt;/strong&gt; Uses one key for both encryption and decryption of the entire session.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Asymmetrical Encryption:&lt;/strong&gt; Uses a public/private key pair (used primarily during the handshake and for authentication).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Hashing:&lt;/strong&gt; Uses algorithms (like HMAC) to ensure data integrity, proving that the packets haven't been altered during transit.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For let's setup simple RSA key pair for ubuntu server.&lt;/p&gt;
&lt;h2&gt;
  
  
  How to Setup SSH
&lt;/h2&gt;

&lt;p&gt;Since we are using ubuntu server, we need to install the SSH server on the server.&lt;/p&gt;
&lt;h3&gt;
  
  
  Step 1: Install the SSH Server
&lt;/h3&gt;

&lt;p&gt;Assuming you are in cloud console want to setup ssh on ubuntu.&lt;/p&gt;

&lt;p&gt;On the server, run:&lt;br&gt;
&lt;/p&gt;

&lt;div class=&quot;highlight js-code-highlight&quot;&gt;
&lt;pre class=&quot;highlight shell&quot;&gt;&lt;code&gt;&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;apt update
&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;apt &lt;span class=&quot;nb&quot;&gt;install &lt;/span&gt;openssh-server
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To check if it&amp;rsquo;s running:&lt;br&gt;
&lt;/p&gt;

&lt;div class=&quot;highlight js-code-highlight&quot;&gt;
&lt;pre class=&quot;highlight shell&quot;&gt;&lt;code&gt;&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;systemctl status ssh
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Step 2: Generate SSH Keys (Recommended)
&lt;/h3&gt;

&lt;p&gt;On your &lt;strong&gt;local machine&lt;/strong&gt;, generate a key pair. This is much safer than using a password.&lt;br&gt;
&lt;/p&gt;

&lt;div class=&quot;highlight js-code-highlight&quot;&gt;
&lt;pre class=&quot;highlight shell&quot;&gt;&lt;code&gt;ssh-keygen &lt;span class=&quot;nt&quot;&gt;-m&lt;/span&gt; PEM &lt;span class=&quot;nt&quot;&gt;-t&lt;/span&gt; rsa &lt;span class=&quot;nt&quot;&gt;-b&lt;/span&gt; 4096 &lt;span class=&quot;nt&quot;&gt;-f&lt;/span&gt; ~/.ssh/private_key
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Press Enter to save it in the default location. &lt;/p&gt;

&lt;p&gt;You can add a passphrase for extra security.&lt;br&gt;
&lt;/p&gt;

&lt;div class=&quot;highlight js-code-highlight&quot;&gt;
&lt;pre class=&quot;highlight shell&quot;&gt;&lt;code&gt;gk@jarvis:~&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;ssh-keygen &lt;span class=&quot;nt&quot;&gt;-m&lt;/span&gt; PEM &lt;span class=&quot;nt&quot;&gt;-t&lt;/span&gt; rsa &lt;span class=&quot;nt&quot;&gt;-b&lt;/span&gt; 4096 &lt;span class=&quot;nt&quot;&gt;-f&lt;/span&gt; ~/.ssh/private_key
Generating public/private rsa key pair.
Enter passphrase &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;empty &lt;span class=&quot;k&quot;&gt;for &lt;/span&gt;no passphrase&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;: 
Enter same passphrase again: 
Your identification has been saved &lt;span class=&quot;k&quot;&gt;in&lt;/span&gt; /home/gk/.ssh/private_key
Your public key has been saved &lt;span class=&quot;k&quot;&gt;in&lt;/span&gt; /home/gk/.ssh/private_key.pub
The key fingerprint is:
SHA256:i3qqpQpyRkjDAdnbe++rN+ZCzak/4Ryzsn5vGJYEsVg gk@jarvis
The key&lt;span class=&quot;s1&quot;&gt;'s randomart image is:
+---[RSA 4096]----+
|o+    E.         |
|o o  o..         |
| + o. ..         |
|..o .   .        |
|. .  . +So       |
| .  . o.@.       |
|o o .o.*.B       |
|oo o .= % .      |
|..o.o++%=*.      |
+----[SHA256]-----+
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the above output, we have generated a private key and public key.&lt;/p&gt;

&lt;p&gt;we can copy public key and save it in server&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 3: Copy the Key to the Server
&lt;/h3&gt;

&lt;p&gt;Copy public key from local machine.&lt;br&gt;
&lt;/p&gt;

&lt;div class=&quot;highlight js-code-highlight&quot;&gt;
&lt;pre class=&quot;highlight shell&quot;&gt;&lt;code&gt;&lt;span class=&quot;nb&quot;&gt;cat&lt;/span&gt; ~/.ssh/private_key.pub
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Once you are inside server either in temperary console or using password.&lt;/p&gt;

&lt;p&gt;Change directory to .ssh&lt;/p&gt;

&lt;p&gt;Add public key to authorized_keys file.&lt;/p&gt;

&lt;p&gt;This way server will trust your public key and you can login without a password.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 4: Connect
&lt;/h3&gt;

&lt;p&gt;Now you can log in without a password:&lt;br&gt;
&lt;/p&gt;

&lt;div class=&quot;highlight js-code-highlight&quot;&gt;
&lt;pre class=&quot;highlight shell&quot;&gt;&lt;code&gt;ssh username@remote_host_ip
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;We understood how ssh works and how to setup ssh on server.&lt;/p&gt;

&lt;p&gt;I hope this article helps you to understand ssh and how to setup ssh on server.&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://github.com/HexmosTech/git-lrc&quot; rel=&quot;noopener noreferrer nofollow&quot;&gt;&lt;img src=&quot;https://media2.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%2Fabn6nl3iehrohehnxgje.png&quot; alt=&quot;git-lrc&quot; width=&quot;800&quot; height=&quot;373&quot;&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Any feedback or contributors are welcome! It&amp;rsquo;s online, source-available, and ready for anyone to use. &lt;br&gt;
&amp;#11088; Star it on GitHub: &lt;a href=&quot;https://github.com/HexmosTech/git-lrc&quot; rel=&quot;noopener noreferrer nofollow&quot;&gt;https://github.com/HexmosTech/git-lrc&lt;/a&gt;&lt;/p&gt;


</description>
<category>Other</category>
<guid isPermaLink="true">https://coderlegion.com/16119/how-does-ssh-work-and-how-can-it-be-set-up</guid>
<pubDate>Wed, 29 Apr 2026 05:42:27 +0000</pubDate>
</item>
</channel>
</rss>