<?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: DiegoGo</title>
    <description>The latest articles on DEV Community by DiegoGo (@dieg0la).</description>
    <link>https://dev.to/dieg0la</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%2F47851%2F9c8abcaf-58a5-4bb8-9d50-b537d17ee41f.jpg</url>
      <title>DEV Community: DiegoGo</title>
      <link>https://dev.to/dieg0la</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/dieg0la"/>
    <language>en</language>
    <item>
      <title>Fighting The Bad Guys in a Fun Way</title>
      <dc:creator>DiegoGo</dc:creator>
      <pubDate>Wed, 24 Jul 2024 05:57:02 +0000</pubDate>
      <link>https://dev.to/dieg0la/fighting-the-bad-guys-in-a-fun-way-22bi</link>
      <guid>https://dev.to/dieg0la/fighting-the-bad-guys-in-a-fun-way-22bi</guid>
      <description>&lt;h2&gt;
  
  
  Phishing Threats
&lt;/h2&gt;

&lt;p&gt;In today's digital age, most people have a bank account that they use daily. Criminal groups have adapted and modernized their methods to steal and extract user information.&lt;/p&gt;

&lt;h3&gt;
  
  
  SMS Spoofing: A Deceptive Technique
&lt;/h3&gt;

&lt;p&gt;SMS spoofing involves sending falsified text messages where the sender appears legitimate, such as a bank. These messages are often grouped with genuine ones from the bank, making the deception more dangerous. Cybercriminals typically hire external services to carry out these falsifications.&lt;/p&gt;

&lt;h3&gt;
  
  
  Case Study: A Fraudulent Message
&lt;/h3&gt;

&lt;p&gt;On one occasion, I received a message that appeared to be from my bank, inviting me to access a fraudulent link. &lt;/p&gt;

&lt;p&gt;So I thought it might be interesting and entertaining to see how that site was displayed.&lt;/p&gt;

&lt;h4&gt;
  
  
  The Original Message
&lt;/h4&gt;

&lt;p&gt;The message was presented as a reliable communication from my bank. The criminals knew the last numbers of my card, suggesting a possible information leak from the bank.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.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%2Fiamnbl3dofsd20te5sgx.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.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%2Fiamnbl3dofsd20te5sgx.png" alt="SMS Spoofing"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Link Analysis
&lt;/h3&gt;

&lt;p&gt;The link only contained the bank's name, which might seem normal to someone who is not familiar with how domains are constructed.&lt;/p&gt;

&lt;p&gt;When running a &lt;code&gt;whois&lt;/code&gt; query on the domain, it returned some interesting data.&lt;/p&gt;

&lt;p&gt;Domain was created on May 27th.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

Domain Name: banorte.link
Creation Date: 2024-05-27T05:21:53.892Z


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;At least, they went to the trouble of not providing certain information.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

Registrant Street: REDACTED FOR PRIVACY
Registrant City: REDACTED FOR PRIVACY
Registrant Postal Code: REDACTED FOR PRIVACY


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;However, there are points where it states that the registrant is located in Mexico.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

Registrant State/Province: Oaxaca
Registrant Country: MX


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h2&gt;
  
  
  Site At First Sight
&lt;/h2&gt;

&lt;p&gt;The site was, in some way, "well-made," featuring colors distinctive to the bank and similar icons, enough to deceive a non-technical person into entering their information. &lt;/p&gt;

&lt;p&gt;However, it lacked a security certificate, which is a significant red flag.&lt;/p&gt;

&lt;p&gt;﻿&lt;a href="https://media.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%2Fxh6ylx2gkrtpvl42ye4m.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.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%2Fxh6ylx2gkrtpvl42ye4m.png" alt="Fraudulent Site"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;It's important to remember that just because a site has a security certificate doesn't mean it is safe and free from scams or phishing. In this case, the criminals didn't even bother to add a certificate.&lt;/p&gt;
&lt;h2&gt;
  
  
  Investigating the Site
&lt;/h2&gt;

&lt;p&gt;Upon examining the site, there's a field for entering data, which suggested that any information submitted would be stored in a database. I used a Python script with Selenium to inject false data into the form.&lt;/p&gt;

&lt;p&gt;Although, I'm not an expert in web programming, but it never hurts to get a little help from ChatGPT, which assisted me in creating a script to inject information into a form.&lt;/p&gt;
&lt;h2&gt;
  
  
  Script Implementation
&lt;/h2&gt;

&lt;p&gt;With the help of a Python script, I managed to inject false information into the site to counter the attack.&lt;/p&gt;

&lt;p&gt;I adapted the script to inject random data, starting with 10 entries, then 30, and finally 50. The data consisted of random characters and numbers with a minimum length of 8 characters, as specified by the criminals for the form submission.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.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%2F72vxb33rtfozr7bhwz35.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.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%2F72vxb33rtfozr7bhwz35.png" alt="Script 1 to 10"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I won't go into the details of the generated script, but I'll focus on the crucial part:&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

input_field = form.find_element(By.NAME, 'form')


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;This line is pivotal, as it uses the &lt;code&gt;find_element&lt;/code&gt; method of the form object to locate an element within that form. The &lt;code&gt;find_element&lt;/code&gt; method is used to search for a single element in the Document Object Model (DOM) of the webpage.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.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%2Fzk5yoqlybabsawhyvf2i.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.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%2Fzk5yoqlybabsawhyvf2i.png" alt="Script 1 to 50"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In this case, the code is looking for an element within the form that has name "form". This is the value of the name attribute of the HTML element being searched for.&lt;/p&gt;

&lt;p&gt;After leaving the script running for at least 1.5 hours, I came back after some time to check and it turns out that nothing was displayed in the site.&lt;/p&gt;

&lt;p&gt;I consulted it using a VPN and using proxychains, to rule out that it was a ban of my IP address, however when I made the query, the page showed the same thing.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.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%2Fymzmy0ynzmjm7nyi6viu.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.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%2Fymzmy0ynzmjm7nyi6viu.png" alt="Site Down"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Final Reflections
&lt;/h2&gt;

&lt;p&gt;I don't claim to have caused a DDoS attack or something similar, but it seems the criminals deactivated the site after receiving false and random data in a short period of time, instead of the expected user credit card or account name information. &lt;/p&gt;

&lt;p&gt;This small counterattack was gratifying, knowing that I might have contributed to preventing innocent people from falling into the trap, at least for that day.&lt;/p&gt;

&lt;p&gt;This case illustrates how criminals can create millions of fraudulent sites daily to steal information and how small actions can have a positive impact on user security.&lt;/p&gt;

&lt;h2&gt;
  
  
  Contributing to Combat Phishing
&lt;/h2&gt;

&lt;p&gt;There are many platforms where you can submit phishing URLs to be reported and indexed on the Internet, assigning them a bad reputation for when someone tries to access them.&lt;/p&gt;

&lt;p&gt;Personally, I use &lt;a href="https://phishtank.org" rel="noopener noreferrer"&gt;PhishTank&lt;/a&gt;, a service managed by Cisco Talos Intelligence Group. This cybersecurity team is dedicated to security research and employs various artificial intelligence techniques to analyze numerous URLs and IPs on the Internet, assigning them a positive or negative score to protect users.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.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%2Fymn0wv9bo5mq17qzsqph.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.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%2Fymn0wv9bo5mq17qzsqph.png" alt="PhishTank"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>cybersecurity</category>
      <category>security</category>
      <category>coding</category>
      <category>python</category>
    </item>
    <item>
      <title>How to setup two factor authentication using DUO security on SSH</title>
      <dc:creator>DiegoGo</dc:creator>
      <pubDate>Mon, 09 May 2022 19:31:09 +0000</pubDate>
      <link>https://dev.to/dieg0la/how-to-setup-two-factor-authentication-using-duo-security-on-ssh-cdk</link>
      <guid>https://dev.to/dieg0la/how-to-setup-two-factor-authentication-using-duo-security-on-ssh-cdk</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;Two-factor authentication or two-step authentication is an important security measure that adds a second layer of protection to the password we use. Adding this extra layer of security makes it more difficult to breach user accounts. today, it is very common to find applications that use two-factor authentication.&lt;/p&gt;

&lt;p&gt;There are several options for using 2FA:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A physical security key: it works like a lock.&lt;/li&gt;
&lt;li&gt;Through an application: Commonly installed on a smartphone and then, when logging in, we will get a message on the device to verify our identity.&lt;/li&gt;
&lt;li&gt;Verification code: this option sends a one-time numeric code, by SMS for example, or by call, which must be entered to verify identity.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Requirements
&lt;/h2&gt;

&lt;p&gt;In this tutorial, we will use DUO security. Which with its free version, we will be able to register up to 10 users.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fabexhbgl7fdk2mvvwqhk.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fabexhbgl7fdk2mvvwqhk.png" alt="DUO free" width="800" height="440"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;To access the DUO administration panel, it is necessary to register a free account at the following link: &lt;a href="https://duo.com/editions-and-pricing/duo-free" rel="noopener noreferrer"&gt;https://duo.com/editions-and-pricing/duo-free&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;A Debian 11 server.&lt;/li&gt;
&lt;li&gt;Basic Linux knowledge.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Steps
&lt;/h2&gt;

&lt;p&gt;Once the DUO account is created, we will be able to access to the dashboard and it will be shown as follows.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyy0onb4kbqxuji2ptobg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyy0onb4kbqxuji2ptobg.png" alt="Dashboard" width="800" height="297"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Inside the dashboard we go to "Applications" and select "Protect an Application", as follows.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqein14cyd1hfdj2xv2bz.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqein14cyd1hfdj2xv2bz.png" alt="Protect an Application" width="800" height="285"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We are going to search "UNIX" and after that, we select "Protect".&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwnm8o5pni1j5wtudbpgg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwnm8o5pni1j5wtudbpgg.png" alt="Protect and Application" width="800" height="428"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;After selecting "Protect" we must save the details that are presented to us, the Integration key, Secret key and the API hostname.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fn0lvk27xgd9tl7d0n9ot.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fn0lvk27xgd9tl7d0n9ot.png" alt="UNIX Application" width="800" height="354"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;After that, up to the bottom, we click on "Save".&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fb4bv41c901hbu8eqv7ck.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fb4bv41c901hbu8eqv7ck.png" alt="Save button" width="800" height="652"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We make sure that in "Applications" we have the application that we have just saved.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqyubhn8ict9irs0cyxxk.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqyubhn8ict9irs0cyxxk.png" alt="Server name" width="800" height="177"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Adding DUO repos security packages
&lt;/h2&gt;

&lt;p&gt;Inside our server, we add the following repository on our sourcelist editing the file &lt;em&gt;/etc/apt/sources.list&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;deb https://pkg.duosecurity.com/Debian bullseye main&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;We add the key&lt;/p&gt;

&lt;p&gt;&lt;code&gt;curl -s https://duo.com/DUO-GPG-PUBLIC-KEY.asc | sudo apt-key add -&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;And proceed to update the repositories and install the duo-unix package&lt;/p&gt;

&lt;p&gt;&lt;code&gt;apt-get update &amp;amp;&amp;amp; apt-get install duo-unix&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Once &lt;em&gt;duo_unix&lt;/em&gt; packet is installed, we proceed to edit &lt;em&gt;pam_duo.conf&lt;/em&gt; in &lt;em&gt;/etc/duo&lt;/em&gt; to add the integration key, secret key, and API hostname from your Duo Unix application.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&lt;br&gt;
[duo]&lt;br&gt;
; Duo integration key&lt;br&gt;
ikey = &amp;lt;integration key&amp;gt;&lt;br&gt;
; Duo secret key&lt;br&gt;
skey = &amp;lt;secret key&amp;gt;&lt;br&gt;
; Duo API hostname&lt;br&gt;
host = &amp;lt;api hostname&amp;gt;&lt;br&gt;
pushinfo=yes&lt;br&gt;
&lt;/code&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Configuring PAM
&lt;/h2&gt;

&lt;p&gt;We are going to use our OpenSSH to use DUO, for that, you are going to set both UsePAM and ChallengeResponseAuthentication to yes in your sshd_config file at /etc/ssh/sshd_config. You should also set UseDNS to no so that PAM Duo is always passed the IP address of the connecting user, rather than the resolved hostname.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&lt;br&gt;
UsePAM yes&lt;br&gt;
ChallengeResponseAuthentication yes&lt;br&gt;
UseDNS no&lt;br&gt;
&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Since we are using a Debian system, the &lt;em&gt;pam_duo.so&lt;/em&gt; module should be found in &lt;em&gt;/lib64/security&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;root@debian11-server:~# ls -lh /lib64/security | grep duo&lt;br&gt;
-rwxr-xr-x 1 root root 921 Feb 2 16:12 pam_duo.la&lt;br&gt;
-rwxr-xr-x 1 root root 437K Feb 2 16:12 pam_duo.so&lt;br&gt;
root@debian11-server:~#&lt;/code&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  What is PAM?
&lt;/h2&gt;

&lt;p&gt;The pluggable authentication module (PAM) in a nuthshell, is a mechanism to integrate multiple low-level authentication schemes into a high-level application programming interface (API). PAM allows programs that rely on authentication to be written independently of the underlying authentication scheme.&lt;br&gt;
&lt;a href="https://www.linux.com/news/understanding-pam/" rel="noopener noreferrer"&gt;https://www.linux.com/news/understanding-pam/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We proceed to configure the following file:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;vim /etc/pam.d/common-auth&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Before:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&lt;br&gt;
auth [success=1 default=ignore] pam_unix.so nullok&lt;br&gt;
auth requisite pam_deny.so&lt;br&gt;
auth required pam_permit.so&lt;br&gt;
&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;After:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&lt;br&gt;
auth [success=2 default=ignore] pam_unix.so nullok&lt;br&gt;
auth sufficient /lib64/security/pam_duo.so&lt;br&gt;
auth requisite pam_deny.so&lt;br&gt;
auth required pam_permit.so&lt;br&gt;
&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;The location of this line and the specified control flag (e.g. "required", "requisite", "sufficient") varies. For most common configurations, place pam_duo directly after pam_unix (frequently found in common-auth or system-auth on Linux), set pam_unix's control flag to "requisite", and set pam_duo's control flag to whatever pam_unix used to be.&lt;/p&gt;

&lt;h2&gt;
  
  
  SSH Public Key Authentication
&lt;/h2&gt;

&lt;p&gt;Now, we proceed to configure this file&lt;br&gt;
&lt;code&gt;vim /etc/pam.d/sshd&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Before:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;@include common-auth&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;After:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&lt;br&gt;
auth required pam_unix.so&lt;br&gt;
auth sufficient /lib64/security/pam_duo.so&lt;br&gt;
auth required pam_deny.so&lt;br&gt;
&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Now, we restart SSH service and login again to the server.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;ssh diego@&amp;lt;debian-server IP address&amp;gt;&lt;br&gt;
(diego@&amp;lt;debian-server IP address&amp;gt;) Password:&lt;br&gt;
Please enroll at https://api-ca19920d.duosecurity.com/portal?code=123456789&amp;amp;akey=abcdefghijklm&lt;br&gt;
(diego@&amp;lt;debian-server IP address&amp;gt;) Password:&lt;br&gt;
&lt;/code&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Enrolling with DUO link
&lt;/h2&gt;

&lt;p&gt;We need to access to the enroll link and follow the steps presented on the browser.&lt;/p&gt;

&lt;p&gt;We click "Start setup"&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fy2w5f516u3xjjg492dun.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fy2w5f516u3xjjg492dun.png" alt="Start setup" width="660" height="369"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We select "Mobile phone" option&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5voown2ucfl3div17dwx.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5voown2ucfl3div17dwx.png" alt="Mobile" width="653" height="382"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We proceed to add out phone number.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frzti1u07j32wwjxml24q.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frzti1u07j32wwjxml24q.png" alt="Phone number" width="659" height="379"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Select our phone brand.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjkglk9vgn83u8xjzcvzs.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjkglk9vgn83u8xjzcvzs.png" alt="Brand" width="653" height="382"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;At this point, we need to have installed the DUO app on our smartphone, DUO app is available for iPhone and Android.&lt;/p&gt;

&lt;p&gt;Click continue on the above step and a QR code will be presented on the screen in where you need to open the DUO app to scan it, after that, the following screen will be presented and click on "Finish Enrollment".&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5hjplp79lnc7vx8t7js2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5hjplp79lnc7vx8t7js2.png" alt="Finish enrollment" width="658" height="379"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;After the above steps, the process is done. Now, we can proceed to login again to our server, and we will be presented with the following information.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;ssh diego@&amp;lt;debian-server IP address&amp;gt;&lt;br&gt;
(diego@&amp;lt;debian-server IP address&amp;gt;) Password:&lt;br&gt;
(diego@&amp;lt;debian-server IP address&amp;gt;) Duo two-factor login for diego&lt;br&gt;
Enter a passcode or select one of the following options:&lt;br&gt;
1 Duo Push to +XX XX XXXX XX95&lt;br&gt;
 2 SMS passcodes to +XX XX XXXX XX95&lt;br&gt;
Passcode or option (1–2):&lt;br&gt;
We hit 1 to receive a push notification on our phone, and after we hit that option and accept it on our phone, we will be able to access to our device.&lt;br&gt;
Passcode or option (1–2): 1&lt;br&gt;
Success. Logging you in…&lt;br&gt;
Success. Logging you in…&lt;br&gt;
Linux debian11-server 5.10.0–11-amd64 #1 SMP Debian 5.10.92–1 (2022–01–18) x86_64&lt;br&gt;
The programs included with the Debian GNU/Linux system are free software;&lt;br&gt;
the exact distribution terms for each program are described in the&lt;br&gt;
individual files in /usr/share/doc/*/copyright.&lt;br&gt;
Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent&lt;br&gt;
permitted by applicable law.&lt;br&gt;
Last login: Sat Apr 23 22:52:59 2022 from x.x.x.x&lt;br&gt;
diego@debian11-server:~$&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;And this is the way how we can setup a 2FA using DUO to login into our server via SSH.&lt;/p&gt;

</description>
      <category>linux</category>
      <category>sysadmin</category>
      <category>security</category>
      <category>2fa</category>
    </item>
    <item>
      <title>Raspberry to the rescue of your privacy - PART TWO</title>
      <dc:creator>DiegoGo</dc:creator>
      <pubDate>Sun, 30 Jun 2019 06:04:33 +0000</pubDate>
      <link>https://dev.to/dieg0la/raspberry-to-the-rescue-of-your-privacy-part-two-jl5</link>
      <guid>https://dev.to/dieg0la/raspberry-to-the-rescue-of-your-privacy-part-two-jl5</guid>
      <description>&lt;p&gt;In part one we set up port forwarding, SSH server and install the web server with all his security stuff.&lt;/p&gt;

&lt;p&gt;Now everything is set up to continue with the installation of the other services&lt;/p&gt;

&lt;h1&gt;
  
  
  Pi-hole
&lt;/h1&gt;

&lt;p&gt;I use some privacy extensions on my browser, such as &lt;a href="https://www.eff.org/privacybadger" rel="noopener noreferrer"&gt;Privacy Badger&lt;/a&gt;, &lt;a href="https://www.eff.org/https-everywhere" rel="noopener noreferrer"&gt;HTTPS Everywhere&lt;/a&gt;,&lt;a href="https://www.mozilla.org/en-US/firefox/facebookcontainer/" rel="noopener noreferrer"&gt;Facebook container&lt;/a&gt; (that is kind of cool to separate your websites and it's build by default on Firefox), &lt;a href="https://addons.mozilla.org/en-US/firefox/addon/pure-url/" rel="noopener noreferrer"&gt;Pure URL&lt;/a&gt; and finally &lt;a href="https://www.ublock.org/" rel="noopener noreferrer"&gt;uBlock&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;I'm a big fan of this last one, because as we know there are many advertisements on pages we visited (yeah yeah I know that many pages are mantained because of ads and clicks) but many times they are annoying.&lt;/p&gt;

&lt;p&gt;But these are addons that I installed on my browser PC, what about my local network devices? such as my smarphone, the smartphone of my parents, brother or a guest, I know there are apps that I can installed and have this, but I'm not going to do this with every guest coming to my house.&lt;/p&gt;

&lt;p&gt;For this purpose is a service called &lt;a href="https://pi-hole.net/" rel="noopener noreferrer"&gt;Pi-hole&lt;/a&gt; &lt;em&gt;"A black hole for Internet advertisements"&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;This service is going to help us to block ads in all our local network devices.&lt;/p&gt;

&lt;p&gt;In the official site is all the step by step installation.&lt;/p&gt;

&lt;h3&gt;
  
  
  Two web servers living together
&lt;/h3&gt;

&lt;p&gt;As we mention before, we are using Apache as our default web server, but to install Pi-hole, we are going to install another web server called Lighttpd. Pi-hole have a web interface dashboard to view the stats, change settings and configure some aspects of our Pi-hole.&lt;/p&gt;

&lt;p&gt;This service is not going to be exposed, this service is only going to serve in our local network, but to see the web interface dashboard, we need to change the default port of Lighttp because it is going to have issues with Apache that servers on port 80.&lt;/p&gt;

&lt;p&gt;When we install Lighttp, automatically the service is up so we are going to stop apache before we install Pi-hole just doing&lt;/p&gt;

&lt;p&gt;&lt;code&gt;# systemctl stop apache&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Once you install Pi-hole you need to change Lighttp port at &lt;code&gt;/etc/lighttpd/lighttpd.conf&lt;/code&gt; changing the &lt;code&gt;server.port&lt;/code&gt; line putting your prefer port&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.imgur.com%2FqkRD1hO.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.imgur.com%2FqkRD1hO.png" alt="lighttpd"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;after doing this you need to restart the service and if everything goes ok, you will be able to see your Pi-hole dashboard in the port you specify.&lt;/p&gt;

&lt;p&gt;In my case it was port 8080, the local ip of my Raspberry is 192.168.1.110 so your dashboard should look like this.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.imgur.com%2FcQbhXld.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.imgur.com%2FcQbhXld.png" alt="dashboard"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Setting up the service on your home router
&lt;/h3&gt;

&lt;p&gt;To use this service as it should be, is necessary to make a change in the DNS addresses of our router as shown below.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.imgur.com%2FgJwcSpS.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.imgur.com%2FgJwcSpS.png" alt="DNS"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You need to add the local address of the Raspberry and so, any device that connects to your network will have the benefits of Pi-hole.&lt;/p&gt;

&lt;p&gt;Summarizing:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Stop Apache service.&lt;/li&gt;
&lt;li&gt;Install Pi-hole and Lighttpd.&lt;/li&gt;
&lt;li&gt;Change Lighttpd port.&lt;/li&gt;
&lt;li&gt;Set Raspberry IP address as DNS in your home router.&lt;/li&gt;
&lt;/ul&gt;

&lt;h1&gt;
  
  
  Your private cloud
&lt;/h1&gt;

&lt;p&gt;I'm not kind of paranoid, but I thing that having your own stuff and infrastructure is cool.&lt;/p&gt;

&lt;p&gt;In this section I'm going to show how I install &lt;a href="https://owncloud.org/" rel="noopener noreferrer"&gt;ownCloud&lt;/a&gt; &lt;em&gt;a file sharing server that puts the control and security of your own data back into your hands.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;I know there are other services such as NextCloud, but this time I'm goig to use this service.&lt;/p&gt;

&lt;h3&gt;
  
  
  Installation
&lt;/h3&gt;

&lt;p&gt;The installation is very easy, we just need to download a compress package and decompress it in our web server folder.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://doc.owncloud.org/server/10.2/admin_manual/installation/" rel="noopener noreferrer"&gt;Manual Installation&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I had some issues starting ownCloud because the server needed some php modules that were not installed, but it was very easy to install them just doing &lt;code&gt;apt search &amp;lt;php-module&amp;gt;&lt;/code&gt; to search the module you need.&lt;/p&gt;

&lt;p&gt;After install all the packages, your ownCloud it will be ready.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.imgur.com%2FhJrP2UA.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.imgur.com%2FhJrP2UA.png" alt="owncloud login"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Note: I follow the recommended configuration of owncloud documentation setting up ownCloud outside of the &lt;a href="https://doc.owncloud.org/server/10.2/admin_manual/installation/manual_installation.html#install-owncloud" rel="noopener noreferrer"&gt;document root&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;After doing this, we are already be able to upload all the things we want even through our cellphone using the ownCloud app.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.imgur.com%2Fv47KyBy.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.imgur.com%2Fv47KyBy.jpg" alt="owcloud app"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Summarizing:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Download the compress package of ownCloud and extract it&lt;/li&gt;
&lt;li&gt;Install the necessary php modules&lt;/li&gt;
&lt;li&gt;Configure Apache&lt;/li&gt;
&lt;li&gt;Downlod the phone app (optional)&lt;/li&gt;
&lt;/ul&gt;

&lt;h1&gt;
  
  
  Your own VPN service
&lt;/h1&gt;

&lt;p&gt;Maybe your are going to say that there are many services running on my tiny little Rasp, but watching the performance is everything ok.&lt;/p&gt;

&lt;p&gt;The final thing I got on the Raspi is my VPN service. I really like this service because is an awesome tool when I'm outside and connected to some public WiFi (obviously checking log in requirements of public WiFi).&lt;/p&gt;

&lt;p&gt;Again, this is very easy to install using &lt;a href="http://www.pivpn.io/" rel="noopener noreferrer"&gt;pivpn&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Note: I know that this install method is automatic and everything is easy and fast. One time I set manually a VPN and for me it was hard, configuring security, keys etc, but at the end this things work you learn a lot doing that stuff. This pivpn method simplified many things and steps.&lt;/p&gt;

&lt;p&gt;The next step will be open a new port in our home router to have access in the outside, we need to open you specify in the installation.&lt;/p&gt;

&lt;p&gt;After install pivpn you need to add clients and generate the private key and the ovpn file that is are going to use to connect to the VPN.&lt;br&gt;
Now we can use OpenVPN aplication in our PC or the app in our phone to connect to our VPN and this is going to be very useful when we want to preserve privacy when we were connect in some public space.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.imgur.com%2FhN2vIo8.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.imgur.com%2FhN2vIo8.jpg" alt="vpnapp"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Summarizing:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Follow the guide of pivpn&lt;/li&gt;
&lt;li&gt;Open the port in our home router&lt;/li&gt;
&lt;li&gt;Generate the keys and the profile&lt;/li&gt;
&lt;li&gt;Copy them to our phone or pc&lt;/li&gt;
&lt;li&gt;Connect to our VPN using the OpenVPN aplication&lt;/li&gt;
&lt;/ul&gt;

&lt;h1&gt;
  
  
  Fail2ban
&lt;/h1&gt;

&lt;p&gt;At this point you will have a device that is exposed to the Internet, maybe in one day if not less you will see a lot of login attempts in your secure logs, that's other reason why I have exposed the Raspi, to learn more about secure, read logs, configure things, etc.&lt;/p&gt;

&lt;p&gt;I install a service call fail2ban that is use to mitigate the brute force attacks by users and bots.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://linuxhandbook.com/fail2ban-basic/" rel="noopener noreferrer"&gt;fail2ban&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  Final thoughts
&lt;/h1&gt;

&lt;p&gt;The first service I put on the Rasp was a middle Tor relay, I took it off because I didn't see that it had a lot of traffic, but also using Tor with a raspberry is a great option.&lt;br&gt;
Also I would like to use the rasp as a honeypot to keep learning more about security.&lt;/p&gt;

&lt;p&gt;As I said at the beginning I dared to write this, first because I believe in share the knowledge is awesome, I like a lot the free software filosophy and I think that the set of services that I'm running, they seem useful to me and maybe for you.&lt;/p&gt;

&lt;p&gt;Thanks a lot to read and any constructive criticism is welcome.&lt;/p&gt;

</description>
      <category>raspberrypi</category>
      <category>privacy</category>
      <category>vpn</category>
      <category>linux</category>
    </item>
    <item>
      <title>Raspberry to the rescue of your privacy - PART ONE</title>
      <dc:creator>DiegoGo</dc:creator>
      <pubDate>Sun, 30 Jun 2019 05:49:56 +0000</pubDate>
      <link>https://dev.to/dieg0la/raspberry-to-the-rescue-of-your-privacy-5f47</link>
      <guid>https://dev.to/dieg0la/raspberry-to-the-rescue-of-your-privacy-5f47</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;The main purpose of this post is to show the many services that you can run on a Raspberry, also I shared the links that I refer to do all the stuff and configurations&lt;/em&gt;.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;I'm faithful believer that the things we do for ourselves, deserve recognition, maybe not public recognition of other person, but a personal one for the work that implies.&lt;/p&gt;

&lt;p&gt;I decided to divide this post into 2 entries, one for setting up the basic web server and the part 2 setting up the other services I had. If you have already running a secure web server you can check the part two.&lt;/p&gt;

&lt;h1&gt;
  
  
  So where do I got with all this?
&lt;/h1&gt;

&lt;p&gt;Nowadays we are in a world that our data is in a far computer of a certain provider, I don't want to seem kind of paranoid but given the risks that exist on the Internet, I prefer to have my own infrastructure that can be access any time, anywhere where I am. &lt;/p&gt;

&lt;p&gt;Ok, ok, maybe is not going to be the best infrastructure, the most fastest, the biggest with a lot of capacity, but at least it's is going to be mine, I'm the owner of it and the best part of this is that I'm be the one who controlled it.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.imgur.com%2FlA0LwEo.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.imgur.com%2FlA0LwEo.png" alt="cloudno"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  Why use a Raspberry?
&lt;/h1&gt;

&lt;p&gt;As many of you know the Raspberry is a low-cost computer, based on ARM architecture and there's a lot of awesome projects you can do with it, domotic, maker stuff, IoT, to name a few. But In this post I'm going to focus specifically to use a Raspberry to our own server, our own cloud, our own storage device and other things that I have tried to experience.&lt;/p&gt;

&lt;h1&gt;
  
  
  First steps
&lt;/h1&gt;

&lt;p&gt;The first thing we need to do, of course is install an OS to the Raspi, there's a lot of flavors to choose.&lt;br&gt;
I choose to install the "default" flavor Raspbian, maybe you're going to said that why this, why not pure Debian (BTW I use Debian testing on my laptop XD) but that's my first choice, maybe later I'm going to put Debian on it.&lt;/p&gt;

&lt;p&gt;Once we log in our Raspbian, we need to configure a static ip to connect vía SSH (previously install) to manage the device. We are not going to use the Raspbian graphical environment so we can disable it entering to a terminal and writing:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;# systemctl set-default multi-user.target&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;This command is going to shut down the graphical environment and put the system into a multi-user command line.&lt;/p&gt;

&lt;p&gt;Summarizing this section, the things we need to do are:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Install the OS.&lt;/li&gt;
&lt;li&gt;Set a static IP.&lt;/li&gt;
&lt;li&gt;Open a terminal to disable the graphical environment.&lt;/li&gt;
&lt;/ul&gt;

&lt;h1&gt;
  
  
  SSH connection
&lt;/h1&gt;

&lt;p&gt;We are using SSH to connect to our device. When we install SSH the default configuration is on, we can log in the device using the password authentication, but this is kind of risky, remember that the device is going to be exposed to the Internet and there are going to be some bad guys, most of the time bots trying to gain access to our device as we are going to see below.&lt;/p&gt;

&lt;p&gt;So we are going to change the SSH configuration file and we are going to use a SSH key-based authentication to our device and use a key to access, we are going to use.&lt;/p&gt;

&lt;p&gt;Also we can follow basic good security practices as disable root password, set the name of the user that is going to authenticate, disable de X11 forwarding.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.digitalocean.com/community/tutorials/how-to-configure-ssh-key-based-authentication-on-a-linux-server" rel="noopener noreferrer"&gt;How To Configure SSH Key-Based Authentication on a Linux Server&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.imgur.com%2FIHbJhED.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.imgur.com%2FIHbJhED.png" alt="ssh"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Summarizing this section:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Change the SSH configuration.&lt;/li&gt;
&lt;li&gt;Disable the password authentication.&lt;/li&gt;
&lt;li&gt;Set up key-based authetication.&lt;/li&gt;
&lt;/ul&gt;

&lt;h1&gt;
  
  
  Setting up
&lt;/h1&gt;

&lt;p&gt;So at this point nothing extraordinary is going on, only basic administration and configuration. As I said at the beginning, we need to expose the device to Internet.&lt;br&gt;
In my case, I have an ISP that gives me a dynamic IP, so I need to have something that help me to connect to the Rasp when the public IP change.&lt;br&gt;
To make this possible I'm using a service called &lt;a href="https://www.noip.com/" rel="noopener noreferrer"&gt;NoIp&lt;/a&gt; that is a service that is going to help us to always have access to our device at any place we are.&lt;/p&gt;

&lt;p&gt;NoIp is a free service that offer us a Dynamic Update Client that is a service that run on our computer and check frecuently when our IP change, so when this happen, this client detect the change and automatically update our hostname to correct the IP.&lt;/p&gt;

&lt;p&gt;It's really easy to set up, the only thing we have to do is Sign Up (no ads, no nothing), set the hostname we want and follow the instructions to install the Dynamic Update Client in our machine.&lt;/p&gt;

&lt;p&gt;When NoIp detect that there have been passed 30 days, they send you an email to refresh your hostname.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.imgur.com%2FqSImTt9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.imgur.com%2FqSImTt9.png" alt="NoIp"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Opening the world to our device
&lt;/h3&gt;

&lt;p&gt;Once we have configured our NoIp service on the Raspi, we need to open the door to the Internet to get exposed, we are going to do this at entering in our home router, select the IP device and set the port forwarding to have remote access.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.imgur.com%2FhlowXi4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.imgur.com%2FhlowXi4.png" alt="Port Forwarding"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As you can see I have  set up some other ports due to the services I'm running on my Raspi. I'm going to cover all, talking about each one according to specific service.&lt;/p&gt;

&lt;p&gt;At this point we are going to be able to access via SSH outside our network, wherever we are.&lt;/p&gt;

&lt;p&gt;When you set up your hostname on NoIp yo see that there is a domain that point directly to your public IP. In my case is diego-go.sytes.net, if we do a ping to this address we will be able to see that is my public address (that maybe is going to change 24hrs or more).&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.imgur.com%2FzeWyDRr.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.imgur.com%2FzeWyDRr.png" alt="ping"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;With this on mind, let's keep on.&lt;/p&gt;

&lt;p&gt;Summarizing this section:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Sign up at NoIp &lt;a href="https://www.noip.com/" rel="noopener noreferrer"&gt;NoIp&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Install the DUC of NoIp.&lt;/li&gt;
&lt;li&gt;Configure the port forwarding on our router.&lt;/li&gt;
&lt;li&gt;Test NoIp hostname&lt;/li&gt;
&lt;/ul&gt;

&lt;h1&gt;
  
  
  Setting up a web server
&lt;/h1&gt;

&lt;p&gt;I know there are many web servers, light and "heavy" ones.&lt;br&gt;
Maybe you are going to think why Apache, if there are others (Nginx, Lighttpd for example), but for this purpose I'm using Apache that I know and always use (have to still learn Nginx I know, don't worry :-D).&lt;/p&gt;

&lt;p&gt;To install is going to be so easy, just type&lt;/p&gt;

&lt;p&gt;&lt;code&gt;# apt install apache2&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;and this is going to install our web server.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.digitalocean.com/community/tutorials/how-to-install-the-apache-web-server-on-debian-9#step-5-%E2%80%94-setting-up-virtual-hosts-(recommended)" rel="noopener noreferrer"&gt;How To Install the Apache Web Server on Debian 9 &lt;/a&gt;&lt;/p&gt;

&lt;p&gt;For the next step, we are going to secure our web server following some of the steps that are in this page.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.tecmint.com/apache-security-tips/" rel="noopener noreferrer"&gt;13 Apache Web Server Security and Hardening Tips&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The things I have set up are:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;How to hide Apache Version and OS Identity from Errors.&lt;/li&gt;
&lt;li&gt;Disable Directory Listing.&lt;/li&gt;
&lt;li&gt;Disable Unnecessary Modules.&lt;/li&gt;
&lt;li&gt;Securing Apache with SSL Certificates.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Obviously this is open to your choice.&lt;/p&gt;

&lt;h3&gt;
  
  
  Securing Apache with SSL certificates
&lt;/h3&gt;

&lt;p&gt;Below I'm going to explain how do I install Owncloud, that is a service to have our own storage service, similar to Dropbox, Google Drive, but this is controlled and administered by us.&lt;/p&gt;

&lt;p&gt;To install the SSL certificates and have https in our web server I'm am going to use Let's Encrypt, that is a Certificate Authority that provides us an easy way to obtain and install certificates.&lt;/p&gt;

&lt;p&gt;I refer to DigitalOcean blog to follow the installation of Let's Encrypt in our Raspi.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.digitalocean.com/community/tutorials/how-to-secure-apache-with-let-s-encrypt-on-debian-9" rel="noopener noreferrer"&gt;How To Secure Apache with Let's Encrypt on Debian 9 &lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Also, you can refer to &lt;a href="https://certbot.eff.org" rel="noopener noreferrer"&gt;certbot website&lt;/a&gt; that show you step by step how to install the cert&lt;/p&gt;

&lt;h3&gt;
  
  
  Opening new ports
&lt;/h3&gt;

&lt;p&gt;At this point we install a web server and a certificate so we need to open new ports on our homer router to reach the web server from outside, so as we do in the SSH section, we need to specify the local ip and set the ports 80 and 443 that it is going to correspond to the web service and the secure web service.&lt;br&gt;
Doing this we will be able to reach our server from outside, even using https protocol.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Note: I force Apache to redirect http to https using a2enmod &lt;a href="https://www.tecmint.com/redirect-http-to-https-on-apache/" rel="noopener noreferrer"&gt;How to Redirect HTTP to HTTPS on Apache&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.imgur.com%2Fft4E5tA.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.imgur.com%2Fft4E5tA.png" alt="https"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Summarizing this section:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Setting up Apache.&lt;/li&gt;
&lt;li&gt;Secure some aspects of the web server.&lt;/li&gt;
&lt;li&gt;Install certificate.&lt;/li&gt;
&lt;li&gt;Open new ports on home router.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://dev.to/dieg0la/raspberry-to-the-rescue-of-your-privacy-part-two-jl5"&gt;Continue with part 2...&lt;/a&gt;&lt;/p&gt;

</description>
      <category>raspberrypi</category>
      <category>privacy</category>
      <category>vpn</category>
      <category>linux</category>
    </item>
  </channel>
</rss>
