<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/"><channel><title>Ssl on MangoDriod</title><link>https://md.eknath.dev/tags/ssl/</link><description>Recent content in Ssl on MangoDriod</description><generator>Hugo -- 0.141.0</generator><language>en-us</language><lastBuildDate>Sat, 13 Sep 2025 11:00:00 +0530</lastBuildDate><atom:link href="https://md.eknath.dev/tags/ssl/index.xml" rel="self" type="application/rss+xml"/><item><title>A Beginner's Guide to Your First Hour on a Linux VPS</title><link>https://md.eknath.dev/posts/software-development/beginners-guide-to-vps-setup/</link><pubDate>Sat, 13 Sep 2025 11:00:00 +0530</pubDate><guid>https://md.eknath.dev/posts/software-development/beginners-guide-to-vps-setup/</guid><description>&lt;p>Congratulations on your new Virtual Private Server (VPS)! This is your own private space on the internet, a blank canvas ready for your projects. That freedom can also be a bit intimidating. What should you do first?&lt;/p>
&lt;p>This guide is designed for the absolute beginner. We will walk through the first essential steps to secure your server, get it ready for projects, and host your first website securely with Nginx and a free SSL certificate.&lt;/p></description><content:encoded><![CDATA[<p>Congratulations on your new Virtual Private Server (VPS)! This is your own private space on the internet, a blank canvas ready for your projects. That freedom can also be a bit intimidating. What should you do first?</p>
<p>This guide is designed for the absolute beginner. We will walk through the first essential steps to secure your server, get it ready for projects, and host your first website securely with Nginx and a free SSL certificate.</p>
<h2 id="1-your-first-login-the-root-user">1. Your First Login: The Root User</h2>
<p>Your hosting provider will give you an IP address (e.g., <code>123.45.67.89</code>) and a password for the <code>root</code> user. The <code>root</code> user is the super-administrator with unlimited power. It&rsquo;s powerful, but also risky to use for everyday tasks.</p>
<h3 id="step-1-connect-to-the-server">Step 1: Connect to the Server</h3>
<p>Open a terminal on your computer and connect to your server using the <code>ssh</code> command.</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>ssh root@YOUR_SERVER_IP
</span></span></code></pre></div><h3 id="step-2-change-the-root-password">Step 2: Change the Root Password</h3>
<p>If your provider gave you a temporary password, your first action should be to change it to something strong and unique.</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>passwd
</span></span></code></pre></div><h2 id="2-create-your-own-user-account">2. Create Your Own User Account</h2>
<p>This is the single most important security step. We will create a standard user account and give it administrative privileges using the <code>sudo</code> command.</p>
<h3 id="step-1-create-the-new-user">Step 1: Create the New User</h3>
<p>Replace <code>devuser</code> with a username you like.</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>adduser devuser
</span></span></code></pre></div><h3 id="step-2-grant-administrative-privileges">Step 2: Grant Administrative Privileges</h3>
<p>Add your new user to the <code>sudo</code> group, which allows it to run commands as the administrator.</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>usermod -aG sudo devuser
</span></span></code></pre></div><h3 id="step-3-log-in-as-your-new-user">Step 3: Log in as Your New User</h3>
<p>Log out of the root account (<code>exit</code>) and log back in with your new credentials.</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>ssh devuser@YOUR_SERVER_IP
</span></span></code></pre></div><p>From now on, you should <strong>always</strong> log in with this user.</p>
<h2 id="3-update-system-and-install-essential-tools">3. Update System and Install Essential Tools</h2>
<p>Now that you are logged in as your new <code>sudo</code> user, the first actions are to update the server and install some essential tools.</p>
<h3 id="step-1-update-the-system">Step 1: Update the System</h3>
<p>This command downloads the latest list of available software (<code>update</code>) and then installs those updates (<code>upgrade</code>).</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>sudo apt update <span style="color:#f92672">&amp;&amp;</span> sudo apt upgrade -y
</span></span></code></pre></div><h3 id="step-2-install-basic-tools">Step 2: Install Basic Tools</h3>
<p>Next, install a few common and useful tools.</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>sudo apt install curl git vim htop unzip nginx -y
</span></span></code></pre></div><p>We include <strong>Nginx</strong> here as it is a lightweight, high-performance web server we will configure later.</p>
<h2 id="4-set-your-timezone">4. Set Your Timezone</h2>
<p>Correct server time is important for logs and many applications. Find your timezone from the list and set it.</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span><span style="color:#75715e"># Find your timezone (press &#39;q&#39; to quit the list)</span>
</span></span><span style="display:flex;"><span>timedatectl list-timezones
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#75715e"># Set your timezone (replace with your own)</span>
</span></span><span style="display:flex;"><span>sudo timedatectl set-timezone Asia/Kolkata
</span></span></code></pre></div><h2 id="5-basic-firewall-setup">5. Basic Firewall Setup</h2>
<p>A firewall is a digital security guard. We will use <code>ufw</code> (Uncomplicated Firewall) to block unwanted traffic.</p>
<h3 id="step-1-allow-essential-traffic">Step 1: Allow Essential Traffic</h3>
<p><strong>This is critical:</strong> You must allow SSH traffic, otherwise the firewall will lock you out. We will also allow Nginx traffic.</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>sudo ufw allow OpenSSH
</span></span><span style="display:flex;"><span>sudo ufw allow <span style="color:#e6db74">&#39;Nginx Full&#39;</span>
</span></span></code></pre></div><p>&lsquo;Nginx Full&rsquo; allows traffic on both HTTP (port 80) and HTTPS (port 443).</p>
<h3 id="step-2-enable-the-firewall">Step 2: Enable the Firewall</h3>
<p>Now, turn the firewall on.</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>sudo ufw enable
</span></span></code></pre></div><h2 id="6-host-a-website-with-nginx">6. Host a Website with Nginx</h2>
<p>Now we will configure Nginx to serve a website for a domain you own.</p>
<h3 id="step-0-point-your-domain-to-the-server-dns">Step 0: Point Your Domain to the Server (DNS)</h3>
<p>Before Nginx can work, you have to tell the internet that your domain should point to your server&rsquo;s IP address. You do this at your <strong>domain registrar</strong> (the company where you bought your domain, like GoDaddy, Namecheap, Google Domains, etc.).</p>
<ol>
<li>Log in to your domain registrar&rsquo;s website.</li>
<li>Find the DNS management page for your domain.</li>
<li>You need to create two <strong>&lsquo;A&rsquo; records</strong>:
<ul>
<li><strong>Record 1 (Root Domain):</strong>
<ul>
<li><strong>Type:</strong> <code>A</code></li>
<li><strong>Host/Name:</strong> <code>@</code> (this symbol represents the root domain itself)</li>
<li><strong>Value/Points to:</strong> Your server&rsquo;s IP address (e.g., <code>123.45.67.89</code>)</li>
<li><strong>TTL (Time to Live):</strong> Leave as default (often 1 hour).</li>
</ul>
</li>
<li><strong>Record 2 (www subdomain):</strong>
<ul>
<li><strong>Type:</strong> <code>A</code></li>
<li><strong>Host/Name:</strong> <code>www</code></li>
<li><strong>Value/Points to:</strong> Your server&rsquo;s IP address (the same one)</li>
<li><strong>TTL:</strong> Leave as default.</li>
</ul>
</li>
</ul>
</li>
</ol>
<p>DNS changes can take anywhere from a few minutes to a few hours to update across the internet.</p>
<h3 id="step-1-create-a-directory-for-your-site">Step 1: Create a Directory for Your Site</h3>
<p>We&rsquo;ll store our website&rsquo;s files in the <code>/var/www</code> directory.</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span><span style="color:#75715e"># Create a directory for your domain</span>
</span></span><span style="display:flex;"><span>sudo mkdir -p /var/www/your-domain.com/html
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#75715e"># Assign ownership to your user</span>
</span></span><span style="display:flex;"><span>sudo chown -R $USER:$USER /var/www/your-domain.com/html
</span></span></code></pre></div><h3 id="step-2-create-a-sample-page">Step 2: Create a Sample Page</h3>
<p>Let&rsquo;s create a simple <code>index.html</code> file for testing.</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>echo <span style="color:#e6db74">&#34;&lt;h1&gt;Hello from my Nginx Site!&lt;/h1&gt;&#34;</span> | sudo tee /var/www/your-domain.com/html/index.html
</span></span></code></pre></div><h3 id="step-3-create-an-nginx-server-block">Step 3: Create an Nginx Server Block</h3>
<p>Nginx uses &ldquo;server block&rdquo; files to know how to handle incoming domains. We&rsquo;ll create one for our domain.</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>sudo nano /etc/nginx/sites-available/your-domain.com
</span></span></code></pre></div><p>Paste the following configuration into the file:</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-nginx" data-lang="nginx"><span style="display:flex;"><span><span style="color:#66d9ef">server</span> {
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">listen</span> <span style="color:#ae81ff">80</span>;
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">listen</span> <span style="color:#e6db74">[::]:80</span>;
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">root</span> <span style="color:#e6db74">/var/www/your-domain.com/html</span>;
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">index</span> <span style="color:#e6db74">index.html</span>;
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">server_name</span> <span style="color:#e6db74">your-domain.com</span> <span style="color:#e6db74">www.your-domain.com</span>;
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">location</span> <span style="color:#e6db74">/</span> {
</span></span><span style="display:flex;"><span>        <span style="color:#f92672">try_files</span> $uri $uri/ =<span style="color:#ae81ff">404</span>;
</span></span><span style="display:flex;"><span>    }
</span></span><span style="display:flex;"><span>}
</span></span></code></pre></div><h3 id="step-4-enable-the-server-block">Step 4: Enable the Server Block</h3>
<p>We enable the site by creating a symbolic link from this file into the <code>sites-enabled</code> directory.</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>sudo ln -s /etc/nginx/sites-available/your-domain.com /etc/nginx/sites-enabled/
</span></span></code></pre></div><p>Now, test your Nginx configuration for errors and restart it.</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>sudo nginx -t
</span></span><span style="display:flex;"><span>sudo systemctl restart nginx
</span></span></code></pre></div><p>Once your DNS has updated, if you visit <code>http://your-domain.com</code> in a browser, you should see your &ldquo;Hello World&rdquo; message.</p>
<h2 id="7-secure-your-site-with-ssl-https">7. Secure Your Site with SSL (HTTPS)</h2>
<p>To secure your site, we&rsquo;ll get a free SSL certificate from Let&rsquo;s Encrypt using a tool called Certbot.</p>
<h3 id="step-1-install-certbot">Step 1: Install Certbot</h3>
<p>Certbot has a dedicated Nginx plugin that makes the process simple.</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>sudo apt install certbot python3-certbot-nginx -y
</span></span></code></pre></div><h3 id="step-2-obtain-the-ssl-certificate">Step 2: Obtain the SSL Certificate</h3>
<p>Run Certbot. It will read your Nginx configuration, see the domain you just set up, and guide you through obtaining the certificate.</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>sudo certbot --nginx
</span></span></code></pre></div><p>Certbot will ask for your email, for you to agree to the terms of service, and if you want to redirect all HTTP traffic to HTTPS. It is highly recommended to choose the redirect option.</p>
<h3 id="step-3-verify-auto-renewal">Step 3: Verify Auto-Renewal</h3>
<p>Let&rsquo;s Encrypt certificates are valid for 90 days. Certbot automatically sets up a task to renew them for you. You can test the renewal process with a dry run.</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>sudo certbot renew --dry-run
</span></span></code></pre></div><p>If this runs without errors, you are all set. Your site is now secure and accessible via <code>https://your-domain.com</code>.</p>
<p><strong>To add a subdomain</strong> (e.g., <code>blog.your-domain.com</code>), you simply repeat the process: create a new directory in <code>/var/www</code>, create a new server block file in <code>sites-available</code>, enable it, and then run <code>sudo certbot --nginx</code> again.</p>
<h2 id="8-quick-tips-and-best-practices">8. Quick Tips and Best Practices</h2>
<ul>
<li>
<p><strong>Use SSH Keys:</strong> Passwords can be cracked. SSH keys are a much more secure way to log in. This is a highly recommended next security step.</p>
</li>
<li>
<p><strong>Keep Your System Updated:</strong> Get in the habit of running <code>sudo apt update &amp;&amp; sudo apt upgrade -y</code> at least once a week.</p>
</li>
<li>
<p><strong>Be Careful with Commands:</strong> Don&rsquo;t run scripts or commands from the internet without understanding what they do.</p>
</li>
<li>
<p><strong>Use Strong Passwords:</strong> The password for your <code>sudo</code> user should be strong and unique.</p>
</li>
</ul>
]]></content:encoded></item></channel></rss>