<?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: fifin-25</title>
    <description>The latest articles on DEV Community by fifin-25 (@fifin25).</description>
    <link>https://dev.to/fifin25</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%2F924745%2Fe31a8e12-0066-476f-9ac1-2112279dc661.png</url>
      <title>DEV Community: fifin-25</title>
      <link>https://dev.to/fifin25</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/fifin25"/>
    <language>en</language>
    <item>
      <title>SSH (Secure Shel)</title>
      <dc:creator>fifin-25</dc:creator>
      <pubDate>Mon, 26 Sep 2022 16:15:43 +0000</pubDate>
      <link>https://dev.to/fifin25/ssh-secure-shel-26c</link>
      <guid>https://dev.to/fifin25/ssh-secure-shel-26c</guid>
      <description>&lt;p&gt;&lt;strong&gt;A. What Is SSH?&lt;/strong&gt;&lt;br&gt;
Secure Shell (SSH) is an adminnistrative protocol that allows users to access and modify various settings and files on the server that can run command bassed on the command line interface (CLI).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;B. How SSH Works&lt;/strong&gt;&lt;br&gt;
The way the SSH protocol works is by implementing a client-server model. The connection that occurs is the SSH client (the computer used by the user) connects to the SSH server (the destination remote server).The SSH process starts from the client that connects and uses the key (SSH Key) to verify the SSH server. To implement the SSH protocol can use the command &lt;em&gt;"ssh username@server_address"&lt;/em&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ETPsEXEc--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wfkhsdwl4gvyrsplx1jc.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ETPsEXEc--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wfkhsdwl4gvyrsplx1jc.png" alt="Image description" width="640" height="227"&gt;&lt;/a&gt;SSH client and SSH server can connect using &lt;strong&gt;the same key&lt;/strong&gt;, as long as the key used by the SSH client is not the same as the SSH server, the connection will never be able to connect.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--a-iOUan---/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/38w6jl2703luzbnx2ymd.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--a-iOUan---/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/38w6jl2703luzbnx2ymd.png" alt="Image description" width="642" height="81"&gt;&lt;/a&gt;When client enters password which is not the same as SSH server then &lt;strong&gt;permission is denied&lt;/strong&gt; then try asking for correct password again to be able to connect with server.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;C. Identifying Remote Users&lt;/strong&gt;&lt;br&gt;
To show which user is logged in using ssh can use the &lt;strong&gt;w&lt;/strong&gt; command.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--zXz_AriX--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fawlxswd8mnmvpi95mbh.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--zXz_AriX--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fawlxswd8mnmvpi95mbh.png" alt="Image description" width="641" height="88"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;D. SSH Host Keys&lt;/strong&gt;&lt;br&gt;
When using SSH protocol There are 2 types of SSH Key. The first is &lt;em&gt;&lt;strong&gt;the Public Key&lt;/strong&gt;&lt;/em&gt; stored on the SSH server and the second is &lt;strong&gt;&lt;em&gt;the Private Key&lt;/em&gt;&lt;/strong&gt; stored on the SSH client.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Generating SSH Keys&lt;/strong&gt;&lt;br&gt;
To create a private key and matching public key for authentication, use the &lt;strong&gt;ssh-keygen&lt;/strong&gt; command.  &lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--0NNsaNUf--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1ozf3v30xz5ae0um56gr.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--0NNsaNUf--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1ozf3v30xz5ae0um56gr.png" alt="Image description" width="641" height="355"&gt;&lt;/a&gt;Notes :&lt;br&gt;
The public key is stored in &lt;em&gt;/home/user/.ssh/id_rsa.pub&lt;/em&gt;&lt;br&gt;
The private key is stored in &lt;em&gt;/home/user/.ssh/id_rsa&lt;/em&gt;&lt;br&gt;
&lt;strong&gt;2. SSH Public Key Tutorial&lt;/strong&gt;&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
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;When prompted for information on where to save the SSH file, just press ENTER on the keyboard.Open the public key with the &lt;strong&gt;cat&lt;/strong&gt; command.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cat /home/user/.ssh/id_rsa.pub
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Copy the contents of id_rsa.pub to the user and follow the destination server.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ssh-copy-id user@server_address
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;While running the above command, you will be prompted for the password for the user. Then try logging in again, and you can log in to the server without needing to enter a password.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ssh user@server_address
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;3. SSH Private Key Tutorial&lt;/strong&gt;&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 -f  ~/.ssh/encrypted_rsa

or can use command

ssh-keygen -f .ssh/key-with-pass
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The -f option with the ssh-keygen command determines the files where the keys are saved. In the preceding example, the private and public keys are saved in the &lt;em&gt;/home/user/.ssh/key-with-pass&lt;/em&gt; &lt;br&gt;
  &lt;em&gt;/home/user/.ssh/key-with-pass.pub&lt;/em&gt; files, respectively. &lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--O-x643Y2--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bp8co3gq8do1nadqtvlz.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--O-x643Y2--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bp8co3gq8do1nadqtvlz.png" alt="Image description" width="641" height="67"&gt;&lt;/a&gt;Enter your password in the Enter passphrase (empty for no passphrase): and Enter the same passphrase again:, the password you typed will not appear, if you are finished press ENTER.&lt;br&gt;
Copy the new public key to the server.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ssh-copy-id -i ~/.ssh/encrypted_rsa.pub user@server_address

or can use

ssh-copy-id -i .ssh/key-with-pass.pub user@server_address
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then try to login&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ssh -i ~/.ssh/encrypted_rsa user@server_address
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This time you have to enter the password used for encryption encrypted_rsa.&lt;/p&gt;

&lt;p&gt;*Private and Public keys will be stored in ~/.ssh, which can be checked with &lt;em&gt;ls -l ~/.ssh&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



</description>
    </item>
  </channel>
</rss>
