<?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: Pritam Bera</title>
    <description>The latest articles on DEV Community by Pritam Bera (@pritambera2000).</description>
    <link>https://dev.to/pritambera2000</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%2F729599%2Fe543e4e1-a86b-4e54-a3d7-2fb8723d512e.jpeg</url>
      <title>DEV Community: Pritam Bera</title>
      <link>https://dev.to/pritambera2000</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/pritambera2000"/>
    <language>en</language>
    <item>
      <title>How To Connect a Remote Server Via SSH</title>
      <dc:creator>Pritam Bera</dc:creator>
      <pubDate>Sat, 15 Jan 2022 16:47:27 +0000</pubDate>
      <link>https://dev.to/pritambera2000/how-to-connect-a-remote-server-via-ssh-3i91</link>
      <guid>https://dev.to/pritambera2000/how-to-connect-a-remote-server-via-ssh-3i91</guid>
      <description>&lt;p&gt;This is a beginner's guide to set up SSH connection on a remote server using &lt;em&gt;Password Authentication&lt;/em&gt; in Linux.&lt;/p&gt;

&lt;h3&gt;
  
  
  What is SSH and Why we need it?
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;SSH&lt;/strong&gt; stands for &lt;strong&gt;Secure Shell&lt;/strong&gt; which is based on client-server protocol, An SSH client program is typically used for establishing secure connections between computers. If you want code execution or transfer files into a remote machine or server in a secure way in the Internet, SSH is the best way to do that. There are many applications of &lt;strong&gt;SSH&lt;/strong&gt; like&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Secure remote access to resources&lt;/li&gt;
&lt;li&gt;Delivery of software patches and updates&lt;/li&gt;
&lt;li&gt;Secure File transfer (sftp) etc.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Enough theory Let's jump into the practical part.&lt;/p&gt;

&lt;h3&gt;
  
  
  Installation of SSH
&lt;/h3&gt;

&lt;p&gt;Most of the Linux Distribution comes with SSH installed within it but if not we can install OpenSSH server easily using this command&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ sudo apt install openssh-client openssh-server
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;Important:&lt;/em&gt; If you are not in a Debian/Ubuntu based distro change "apt" according to your distribution's package manager.&lt;br&gt;
&lt;em&gt;Pro-tip:&lt;/em&gt; If you system uses systemD as init system and booted with systemD you can use &lt;code&gt;systemctl&lt;/code&gt; command. OtherWise Google for specific command.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--meIGqyeG--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ls5p3uxroc1k0pf5qein.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--meIGqyeG--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ls5p3uxroc1k0pf5qein.png" alt="Installing OpenSSH server" width="622" height="171"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Checking Status of sshd
&lt;/h2&gt;

&lt;p&gt;Let's check SSH daemon is running/active or not in our system, this can be done by this command&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ sudo systemctl status sshd
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;or&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ sudo service ssh status
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--E0lXkpp6--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/r2m0opk0vghzg3bwohcb.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--E0lXkpp6--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/r2m0opk0vghzg3bwohcb.png" alt="Checking Status of sshd" width="794" height="296"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;if the service is inactive/dead , start the service using this command&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ sudo systemctl start sshd
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;or&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ sudo service ssh start
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--vFK2TEOD--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/licr66iqry28kcfkao3b.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--vFK2TEOD--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/licr66iqry28kcfkao3b.png" alt="Service ssh start" width="752" height="273"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Configuration of ssh
&lt;/h3&gt;

&lt;p&gt;We don't need to deep dive into ssh config just take a look at some important configuration stored in  the &lt;code&gt;/etc/ssh/sshd_config&lt;/code&gt; file. Open the file in a text editor, i'm using vim&lt;br&gt;
&lt;code&gt;sudo vim /etc/ssh/sshd_config&lt;/code&gt;&lt;br&gt;
by default, SSH uses port 22&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--lTy5nrxG--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/d8hh2ua186ulanylb7wf.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--lTy5nrxG--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/d8hh2ua186ulanylb7wf.png" alt="SSH Config Port 22" width="720" height="375"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If Password Auth is disabled by default , turn it on&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--OXZIL042--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1p8ukua62yqhcii1q1a9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--OXZIL042--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1p8ukua62yqhcii1q1a9.png" alt="SSH config passwd auth yes" width="734" height="142"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;and turn X11 forwarding on&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--6aWIflap--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/kbs6wrrwng7u44gufb4w.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--6aWIflap--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/kbs6wrrwng7u44gufb4w.png" alt="SSH config X11 yes" width="646" height="303"&gt;&lt;/a&gt;&lt;br&gt;
then reload the config&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ sudo systemctl restart sshd
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Connect SSH into remote Machine
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ ssh remote-username@remote-ip
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Ezi3nuZb--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wg5fzv05rjnvn2eoc05h.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Ezi3nuZb--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wg5fzv05rjnvn2eoc05h.png" alt="SSH username@ip  in remote" width="751" height="141"&gt;&lt;/a&gt;&lt;br&gt;
It will prompt you to enter password of the machine type the password  &amp;amp; you should be in the server :)&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--sYAOgUhR--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9eh2gug65qrdb835pds1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--sYAOgUhR--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9eh2gug65qrdb835pds1.png" alt="SSH Sucessful Login" width="864" height="435"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;incase if you are not familiar with CLI you can find ip by &lt;code&gt;$ ifconfig&lt;/code&gt; or &lt;code&gt;$ ip a&lt;/code&gt; command&lt;/p&gt;

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

&lt;h2&gt;
  
  
  Commands at a glance
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ sudo apt install openssh-client openssh-server
$ sudo service ssh status
$ sudo service ssh start
$ sudo systemctl restart sshd
$ ssh remote-username@remote-ip
$ ifconfig
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>linux</category>
      <category>beginners</category>
      <category>tutorial</category>
      <category>ubuntu</category>
    </item>
  </channel>
</rss>
