<?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: Mike</title>
    <description>The latest articles on DEV Community by Mike (@mikeodev).</description>
    <link>https://dev.to/mikeodev</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%2F131927%2Fa2a97a3f-7270-4cce-886c-7ae1767b7566.jpg</url>
      <title>DEV Community: Mike</title>
      <link>https://dev.to/mikeodev</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/mikeodev"/>
    <language>en</language>
    <item>
      <title>Connect to your VPS with SSH</title>
      <dc:creator>Mike</dc:creator>
      <pubDate>Fri, 12 Jun 2020 14:29:24 +0000</pubDate>
      <link>https://dev.to/mikeodev/connect-to-your-vps-with-ssh-3cim</link>
      <guid>https://dev.to/mikeodev/connect-to-your-vps-with-ssh-3cim</guid>
      <description>&lt;h1&gt;
  
  
  Prerequisites
&lt;/h1&gt;

&lt;ul&gt;
&lt;li&gt;You have deployed a VPS with Ubuntu. (Vultr, Digital Ocean, Etc.)
Here's a &lt;a href="https://www.vultr.com/?ref=7515469"&gt;Referral Link for Vultr&lt;/a&gt; if you want to try them out. (no biggy if you don't want to though).&lt;/li&gt;
&lt;li&gt;You have installed PuTTY on your local Desktop.&lt;/li&gt;
&lt;li&gt;You have a separate user setup on your server with sudo privileges.&lt;/li&gt;
&lt;/ul&gt;

&lt;h1&gt;
  
  
  Create Your Keys
&lt;/h1&gt;

&lt;p&gt;When you install &lt;strong&gt;PuTTY&lt;/strong&gt; it will also come with an application called &lt;strong&gt;PuTTYgen&lt;/strong&gt;. Launch &lt;strong&gt;PuTTYgen&lt;/strong&gt; and follow the steps below.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Keep the default settings of &lt;strong&gt;RSA&lt;/strong&gt; and &lt;strong&gt;2048 bits&lt;/strong&gt; . &lt;/li&gt;
&lt;li&gt;Click &lt;strong&gt;Generate&lt;/strong&gt; and move your mouse around until the key has been built.&lt;/li&gt;
&lt;li&gt;Once generated, Create a &lt;strong&gt;Key Passphrase&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Then save the &lt;strong&gt;Public Key&lt;/strong&gt;, and &lt;strong&gt;Private Key&lt;/strong&gt; somewhere local on your computer.&lt;/li&gt;
&lt;li&gt;Keep the application open while we move onto the next step, so you can use the public key for copy/pasting.&lt;/li&gt;
&lt;/ul&gt;

&lt;h1&gt;
  
  
  Create the SSH Directory and File
&lt;/h1&gt;

&lt;p&gt;Now that we have our keys generated, we are going to create the directory and file needed on our server. Open up a current remote connection to your server and follow the steps below.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;WARNING&lt;/strong&gt;: Do &lt;strong&gt;NOT&lt;/strong&gt; run the directory and file creation commands with &lt;strong&gt;sudo&lt;/strong&gt; privileges.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Create a hidden directory called .ssh within your users home directory.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;mkdir&lt;/span&gt; ~/.ssh
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Create a file called 'authorized_keys'
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;nano ~/.ssh/authorized_keys
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;An empty file ready to be edited will be opened in your terminal. Copy/Paste the Public Key from the PuTTYgen application we left open.&lt;/li&gt;
&lt;li&gt;NOTE: if you closed the application by accident, just relaunch PuTTYgen and click Load. Navigate to your Public Key and load it into PuTTYgen.&lt;/li&gt;
&lt;li&gt;Exit and save the file. &lt;strong&gt;ctrl-x&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;Finally, change the permissions for the directory and file with the following command.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;chmod &lt;/span&gt;700 &lt;span class="nt"&gt;-R&lt;/span&gt; ~/.ssh &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nb"&gt;chmod &lt;/span&gt;600 ~/.ssh/authorized_keys
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h1&gt;
  
  
  Test the SSH Connection
&lt;/h1&gt;

&lt;p&gt;Now we are going to test out our SSH connection using PuTTY. &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Navigate to your &lt;strong&gt;Private Key File&lt;/strong&gt; we saved earlier and &lt;strong&gt;Double Click&lt;/strong&gt; on it.&lt;/li&gt;
&lt;li&gt;Enter your &lt;strong&gt;Passphrase&lt;/strong&gt; you created earlier when prompted.&lt;/li&gt;
&lt;li&gt;Now, Launch the regular &lt;strong&gt;PuTTY&lt;/strong&gt; application on your desktop.&lt;/li&gt;
&lt;li&gt;Enter your &lt;strong&gt;Server's IP&lt;/strong&gt; address into the &lt;strong&gt;Host Name&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Leave the rest of the default settings alone and &lt;strong&gt;Click Open&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;If this is your first time remotely connecting to this server you will be prompted by a security warning asking if you trust the server. You can select Yes. If you are interested in how you can actually verify this, follow my additional step below with the header &lt;strong&gt;Verify Remote Server (optional)&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;A terminal window will open and prompt you for the user you would like to sign in with. &lt;strong&gt;Enter your user name&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Next the magic happens. You will see your SSH key being &lt;strong&gt;Authenticated&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Once that completes, you'll be &lt;strong&gt;logged in officially via SSH!&lt;/strong&gt; =)&lt;/li&gt;
&lt;/ul&gt;

&lt;h1&gt;
  
  
  Verify Remote Server (optional)
&lt;/h1&gt;

&lt;p&gt;When you first connect to your remote server you will be prompted to verify and confirm you trust the server you are connecting to. The prompt will show you a string that you can use to verify this connection with the steps below.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Open a Local Connection to your server. Most VPS host provide a way to do this within the Servers Dashboard.&lt;/li&gt;
&lt;li&gt;Once connected locally, use the following commands to obtain strings you can match against the ones shown on the security warning prompt.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;ssh-keygen &lt;span class="nt"&gt;-l&lt;/span&gt; &lt;span class="nt"&gt;-f&lt;/span&gt; /etc/ssh/ssh_host_ed25519_key
ssh-keygen &lt;span class="nt"&gt;-l&lt;/span&gt; &lt;span class="nt"&gt;-f&lt;/span&gt; /etc/ssh/ssh_host_ed25519_key &lt;span class="nt"&gt;-E&lt;/span&gt; md5
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Thanks for Reading! &lt;/p&gt;

</description>
      <category>ssh</category>
      <category>vps</category>
      <category>server</category>
      <category>ubuntu</category>
    </item>
  </channel>
</rss>
