<?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: Dhirva Makadiya</title>
    <description>The latest articles on DEV Community by Dhirva Makadiya (@dhirva).</description>
    <link>https://dev.to/dhirva</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%2F1458196%2F40f5e71e-1bcb-428c-84e7-abc2ee5e499a.jpeg</url>
      <title>DEV Community: Dhirva Makadiya</title>
      <link>https://dev.to/dhirva</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/dhirva"/>
    <language>en</language>
    <item>
      <title>Set up FreeIPA Server &amp; Client.</title>
      <dc:creator>Dhirva Makadiya</dc:creator>
      <pubDate>Thu, 09 May 2024 06:18:00 +0000</pubDate>
      <link>https://dev.to/dhirva/set-up-freeipa-server-client-4kn7</link>
      <guid>https://dev.to/dhirva/set-up-freeipa-server-client-4kn7</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;In this guide, we'll set up a FreeIPA server and client on AWS EC2 instances using CentOS 9, restrict particular users to allow/deny SSH to a particular client, and also restrict the particular user to allow/deny only particular sudo commands inside the client.&lt;/p&gt;
&lt;/blockquote&gt;

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

&lt;p&gt;FreeIPA aims to provide a centrally managed Identity, Policy, and Audit (IPA) system. It is an integrated Identity and Authentication solution for Linux/UNIX networked environments. A FreeIPA server provides centralized authentication, authorization, and account information by storing data about users, groups, hosts, and other objects necessary to manage the security aspects of a network of computers.&lt;/p&gt;

&lt;h2&gt;
  
  
  Advantages of FreeIPA
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Convenient User and Group Management&lt;/strong&gt;: FreeIPA provides an interface for creating, editing, and deleting users and groups. This simplifies the tasks of administrators to manage user access.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Centralized Management&lt;/strong&gt;: Administrators can centrally manage and monitor users and devices on the network, which increases security and facilitates administration.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Free and Open-Source&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Enhanced Security&lt;/strong&gt;: The platform provides mechanisms for two-factor authentication, centralized management of certificates and keys, and role-based access control.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Setup FreeIPA Server and Client&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;1. Provision EC2 Instances&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Launch two EC2 instances:
Server: FreeIPA Server
Client: FreeIPA Client&lt;/li&gt;
&lt;li&gt;Attach Elastic IP (EIP) to each instance for static public IP.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;2. Initial Setup on FreeIPA Server&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

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

yum update -y
dnf install nano
dnf install firewalld
systemctl enable firewalld
systemctl start firewalld


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

&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;3.  Configure DNS Records&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Log in to GoDaddy and navigate to your domain management.&lt;/li&gt;
&lt;li&gt;Add DNS records for FreeIPA domains:&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;code&gt;ipa.letsgoanywhere.info&lt;/code&gt; pointing to FreeIPA Server's public IP&lt;br&gt;
&lt;code&gt;free.ipa.letsgoanywhere.info&lt;/code&gt; pointing to FreeIPA Server's public IP&lt;br&gt;
&lt;code&gt;client.ipa.letsgoanywhere.info&lt;/code&gt; pointing to FreeIPA Client's public IP&lt;br&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%2Fo4bu8znnhsndex2ntwe7.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%2Fo4bu8znnhsndex2ntwe7.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;4. Configure FreeIPA Server&lt;/em&gt;&lt;/strong&gt;&lt;br&gt;
Connect to the server through SSH&lt;/p&gt;

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

echo "&amp;lt;server_private_ip&amp;gt; free.ipa.letsgoanywhere.info" | sudo tee -a /etc/hosts
echo "free.ipa.letsgoanywhere.info" | sudo tee /etc/hostname
sudo reboot

# After reboot:
sudo yum install ipa-server ipa-server-dns -y
sudo firewall-cmd --permanent --add-service={dns,ntp,http,https,ldap,ldaps,kerberos,kpasswd}
sudo firewall-cmd --reload
sudo ipa-server-install --setup-dns


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

&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;NOTE:&lt;/strong&gt; Remember the following values while setting up FreeIPA server dns&lt;br&gt;
&lt;em&gt;Hostname&lt;/em&gt; : &lt;code&gt;free.ipa.letsgoanywhere.info&lt;/code&gt;&lt;br&gt;
&lt;em&gt;Domainname&lt;/em&gt;: &lt;code&gt;ipa.letsgoanywhere.info&lt;/code&gt;&lt;br&gt;
&lt;em&gt;IP&lt;/em&gt; : &lt;code&gt;&amp;lt;Private ip of IPA server&amp;gt;&lt;/code&gt;&lt;br&gt;
&lt;em&gt;Continue to configure system with these values&lt;/em&gt;: &lt;code&gt;yes&lt;/code&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;To obtain a ticket-granting, run the following command:&lt;br&gt;
&lt;code&gt;kinit admin&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Access FreeIPA web UI using the FreeIPA Server's public IP. Log in as admin with the admin password.&lt;br&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%2Fxy4ps28yg5mugp365rv1.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%2Fxy4ps28yg5mugp365rv1.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Add a new user and explore user management features. By default only one admin user is present.&lt;br&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%2F6ichvnlc6al16qz0epcf.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%2F6ichvnlc6al16qz0epcf.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;5. Configure FreeIPA Client&lt;/em&gt;&lt;/strong&gt;&lt;br&gt;
Connect to the client through SSH&lt;/p&gt;

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

sudo yum update -y
sudo dnf install nano

# Update hostname and hosts file
sudo hostnamectl set-hostname client.ipa.letsgoanywhere.info
echo "&amp;lt;private-ip-of-client&amp;gt; client.ipa.letsgoanywhere.info" | sudo tee -a /etc/hosts
echo "&amp;lt;private-ip-of-server&amp;gt; free.ipa.letsgoanywhere.info" | sudo tee -a /etc/hosts

# Install and configure FreeIPA client
sudo yum install ipa-client -y
sudo ipa-client-install --hostname=client.ipa.letsgoanywhere.info --mkhomedir --server=free.ipa.letsgoanywhere.info --domain=ipa.letsgoanywhere.info --realm=IPA.LETSGOANYWHERE.INFO



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

&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;NOTE:&lt;/strong&gt; Remember the following values while setting up the FreeIPA client&lt;br&gt;
&lt;em&gt;Proceed with fixed values and no DNS discovery&lt;/em&gt;: &lt;code&gt;yes&lt;/code&gt; (Check all client and server hostnames and domain names)&lt;br&gt;
&lt;em&gt;Continue to configure the system with these values&lt;/em&gt;: &lt;code&gt;yes&lt;/code&gt;&lt;br&gt;
&lt;em&gt;User authorized to enroll computers&lt;/em&gt;: &lt;code&gt;Username: admin and Password: &amp;lt;which we had set up for IPA admin server setup&amp;gt;&lt;/code&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;After the server and client are connected it will show two hosts in FreeIPA server. Initially, before the client setup, there was only one host present.
&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%2Fzegyipylk44kasuh8fd7.png" alt="Image description"&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;6. Testing&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Test connectivity from the FreeIPA Server to the FreeIPA Client.
To connect to FreeIPA client first we need to connect to FreeIPA server and inside it we will SSH with client's IP.
```
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;ssh @&lt;/p&gt;

&lt;h1&gt;
  
  
  Example: ssh &lt;a href="mailto:abc@54.175.68.226"&gt;abc@54.175.68.226&lt;/a&gt;
&lt;/h1&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5fs3jt5zlnc58l618ej0.png)

## **Restrict/Allow particular user to connect(SSH) to any particular client**

1. Create a user which you want to restrict to SSH to particular client
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6ichvnlc6al16qz0epcf.png)
2. Go to Policy &amp;gt; HBAC rule and disable the current rules
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/g36w9k6abd1ewmd80x4t.png)
3. Add new HBAC rule where we allow only demo user to SSH to client and no other user is allowed to SSH to that particular client.
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2nhambs41y9wiyutxltj.png)
4. Test: If we SSH using the demo user we can connect to a client but if we SSH using user2 it shows permission denied as we have allowed only demo user to connect to client.
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qaucfdq1qj69f00vwjnv.png) 

## **Restrict/Allow particular user to execute commands inside client**

1. Go to Policy &amp;gt; Sudo &amp;gt; Sudo commands. Add commands which you want to allow demo user to execute using sudo.
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6n0co9gt0ntffxekglrk.png)
2. Create sudo command group and add the sudo commands inside this group
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/eadu7n0xmn82omua5x9n.png)
3. Create a sudo rule where we will allow the demo user to execute the `sudo touch demo.txt` command only. All other sudo commands will be denied by default.
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xniiqb8zhrg8qsrlwmha.png)
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/66zrwpgt84ccc3l9d58n.png)

4. Test: Using demo user if we run `sudo touch demo.txt`, it is allowed. But if we run `sudo touch demo.pdf`, it shows permission denied.
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5uxcdcryzmd0r65a5wlr.png)

## **Conclusion**

&amp;gt; By following these steps, you'll have a fully functional FreeIPA server and client setup integrated with a custom domain. 
Most importantly we have restricted users to allow/deny to execute sudo commands and to ssh to particular clients using FreeIPA server. This configuration enables secure identity management and user authentication using FreeIPA.

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

&lt;/div&gt;

</description>
      <category>aws</category>
      <category>devsecops</category>
      <category>security</category>
      <category>cloud</category>
    </item>
    <item>
      <title>Set up Pritunl Server and Integrate with Filebeat, Elasticsearch &amp; Kibana for getting logs and alerts.</title>
      <dc:creator>Dhirva Makadiya</dc:creator>
      <pubDate>Thu, 02 May 2024 11:16:15 +0000</pubDate>
      <link>https://dev.to/dhirva/set-up-pritunl-server-and-integrate-with-filebeat-elasticsearch-kibana-for-getting-logs-and-alerts-4ogg</link>
      <guid>https://dev.to/dhirva/set-up-pritunl-server-and-integrate-with-filebeat-elasticsearch-kibana-for-getting-logs-and-alerts-4ogg</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;In this comprehensive guide, we’ll walk through the process of setting up a Pritunl VPN server on Ubuntu 22.04 instance. We’ll then integrate the Pritunl server logs with Filebeat, Elasticsearch, and Kibana to visualize and monitor VPN activities and set up alerts for specific events.&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  What is Pritunl Server?
&lt;/h2&gt;

&lt;p&gt;Pritunl Server is an open-source VPN server that's easy to set up and manage through a web-based interface. It supports various authentication methods, offers scalability for large deployments, and works on multiple platforms. Key features include security with two-factor authentication, high availability configurations, and built-in logging and monitoring. It's a user-friendly solution for setting up VPNs in businesses and enterprises.&lt;/p&gt;

&lt;h2&gt;
  
  
  Benefits of the Pritunl server over VPN:
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Simplicity:&lt;/strong&gt; Using the web interface or command line, you can easily install and configure Pritunl VPN on your server. You can also connect to VPN networks using the free and cross-platform Pritunl client or any other client supporting OpenVPN.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Security:&lt;/strong&gt; You can be sure that your traffic is protected by strong encryption and authentication using OpenVPN standards and protocols. &lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Openness:&lt;/strong&gt; You can use Pritunl VPN for free.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Integration:&lt;/strong&gt; Using API and webhooks, you can integrate Pritunl VPN with other applications and platforms. For example, you can integrate Pritunl VPN with your Identity Management System (IAM), such as Active Directory, LDAP, or SAML.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Deploying Pritunl Server&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;1. Launch EC2 Instance and Private Server&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Launch an Ubuntu 22.04 instance and one private instance within the same VPC.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;2. Create Installation Script for Pritunl&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Create a bash script named install_pritunl.sh with the following content to set up Pritunl and MongoDB:
```
&lt;/li&gt;
&lt;/ul&gt;

&lt;h1&gt;
  
  
  !/bin/bash
&lt;/h1&gt;

&lt;h1&gt;
  
  
  Add Pritunl repository
&lt;/h1&gt;

&lt;p&gt;sudo tee /etc/apt/sources.list.d/pritunl.list &amp;lt;&amp;lt; EOF&lt;br&gt;
deb &lt;a href="http://repo.pritunl.com/stable/apt" rel="noopener noreferrer"&gt;http://repo.pritunl.com/stable/apt&lt;/a&gt; jammy main&lt;br&gt;
EOF&lt;/p&gt;

&lt;h1&gt;
  
  
  Import Pritunl signing key
&lt;/h1&gt;

&lt;p&gt;sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com --recv 7568D9BB55FF9E5287D586017AE645C0CF8E292A&lt;/p&gt;

&lt;h1&gt;
  
  
  Update package repository
&lt;/h1&gt;

&lt;p&gt;sudo apt update&lt;/p&gt;

&lt;h1&gt;
  
  
  Install WireGuard and Pritunl
&lt;/h1&gt;

&lt;p&gt;sudo apt -y install wireguard wireguard-tools&lt;br&gt;
sudo apt -y install pritunl mongodb-org&lt;/p&gt;

&lt;h1&gt;
  
  
  Enable and start services
&lt;/h1&gt;

&lt;p&gt;sudo systemctl enable mongod pritunl&lt;br&gt;
sudo systemctl start mongod pritunl&lt;/p&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;- Run the script:
`. ./install_pritunl.sh`

**_3. Configure Pritunl Server_**
- Access the Pritunl web interface using the public IP over HTTPS.
- Sign up
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rs3h1tm7uv89791fpsdm.png)
- Create organization
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hhrg204hj7cen4o756wg.png)
- Create a user inside the organization that you created
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dxr1zw8cs0iyya7zqvak.png)
- Add a server
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xn0jyk08wn09xa6pn9q8.png)
- Attach the server to the organization that you created
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tkpaoy9i20pd9nb7xmcy.png)
- Download the user's profile by going to the temporary profile link and download the zip file. Unzip that ovpn file.
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rt8t3dcg625m99a80kcf.png)
- Download OpenVPN if not present
- Inside OpenVPN add the user's profile and connect to the Pritunl server. Add username and password of pritunl login . Add a response pin which is set when we create a user.
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hqacfn8xwfjtw6oemb9v.png)
- Successfully connected to the Pritunl VPN.
- Now we will test whether we can connect(SSH) our private server which is in the same VPC network when we are connected to pritunl VPN.
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/w3k3ybi2zszhfk4l4971.png)
We can successfully SSH to our private server if they are in the same network and connected to our Pritunl VPN server. 

## **Integrating Pritunl Logs with Elasticsearch and Kibana using Filebeat.**

**_1. Install Elasticsearch_**
- Install and configure Elasticsearch for log storage:
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;wget -qO - &lt;a href="https://artifacts.elastic.co/GPG-KEY-elasticsearch" rel="noopener noreferrer"&gt;https://artifacts.elastic.co/GPG-KEY-elasticsearch&lt;/a&gt; | sudo apt-key add -&lt;br&gt;
sudo apt-get install apt-transport-https&lt;br&gt;
echo "deb &lt;a href="https://artifacts.elastic.co/packages/8.x/apt" rel="noopener noreferrer"&gt;https://artifacts.elastic.co/packages/8.x/apt&lt;/a&gt; stable main" | sudo tee /etc/apt/sources.list.d/elastic-8.x.list&lt;br&gt;
sudo apt-get update&lt;br&gt;
sudo apt-get install elasticsearch&lt;/p&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
_**2. Configure Elasticsearch**_
- Edit /etc/elasticsearch/elasticsearch.yml with the following settings:
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;cluster.name: my-application&lt;br&gt;
node.name: node-1&lt;br&gt;
path.data: /var/lib/elasticsearch&lt;br&gt;
path.logs: /var/log/elasticsearch&lt;br&gt;
network.host: localhost&lt;br&gt;
http.port: 9200&lt;br&gt;
discovery.seed_hosts: ["127.0.0.1"]&lt;br&gt;
xpack.security.enabled: false&lt;/p&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;- Start Elasticsearch service:
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;sudo systemctl enable elasticsearch.service&lt;br&gt;
sudo systemctl start elasticsearch.service&lt;/p&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;- Access Elasticsearch at _http://public-ip-address:9200_
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9w41bwhfxeo2k4e2mmpf.png)

**_3. Install and Configure Filebeat_**
- Install and configure Filebeat to ship logs to Elasticsearch:
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;curl -L -O &lt;a href="https://artifacts.elastic.co/downloads/beats/filebeat/filebeat-8.0.0-amd64.deb" rel="noopener noreferrer"&gt;https://artifacts.elastic.co/downloads/beats/filebeat/filebeat-8.0.0-amd64.deb&lt;/a&gt;&lt;br&gt;
sudo dpkg -i filebeat-8.0.0-amd64.deb&lt;br&gt;
sudo nano /etc/filebeat/filebeat.yml&lt;/p&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;- Example filebeat.yml configuration:
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;filebeat.inputs:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;type: log
paths:

&lt;ul&gt;
&lt;li&gt;/var/log/pritunl.log&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;

&lt;p&gt;output.elasticsearch:&lt;br&gt;
  hosts: ["localhost:9200"]&lt;br&gt;
  username: "your_username"&lt;br&gt;
  password: "your_password"&lt;/p&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;- Start and enable Filebeat:

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

&lt;/div&gt;



&lt;p&gt;sudo systemctl enable filebeat&lt;br&gt;
sudo systemctl start filebeat&lt;/p&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
**_4.  Install and Configure Kibana_**
- Install and configure Kibana for log visualization:
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;wget -qO - &lt;a href="https://artifacts.elastic.co/GPG-KEY-elasticsearch" rel="noopener noreferrer"&gt;https://artifacts.elastic.co/GPG-KEY-elasticsearch&lt;/a&gt; | sudo apt-key add -&lt;br&gt;
sudo apt-get install apt-transport-https&lt;br&gt;
echo "deb &lt;a href="https://artifacts.elastic.co/packages/7.x/apt" rel="noopener noreferrer"&gt;https://artifacts.elastic.co/packages/7.x/apt&lt;/a&gt; stable main" | sudo tee -a /etc/apt/sources.list.d/elastic-7.x.list&lt;br&gt;
sudo apt-get update&lt;br&gt;
sudo apt-get install kibana&lt;br&gt;
sudo nano /etc/kibana/kibana.yml&lt;/p&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;- Example kibana.yml configuration:
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;server.port: 5601&lt;br&gt;
server.host: 0.0.0.0&lt;br&gt;
elasticsearch.hosts: ["&lt;a href="http://localhost:9200%22" rel="noopener noreferrer"&gt;http://localhost:9200"&lt;/a&gt;]&lt;/p&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;- Start and enable Kibana:
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;sudo systemctl enable kibana&lt;br&gt;
sudo systemctl start kibana&lt;/p&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
**_5. Setting Up Alerts in Kibana_**
- Access Kibana at http://public-ip-address:5601.
- Navigate to Discover and configure the message and timestamp fields.
- In Observability, go to Alerts &amp;gt; Manage Rules.
- Create a new rule with conditions based on Pritunl logs (e.g., Authenticating user).
- We will create a rule that whenever a user connects to our Pritunl VPN server we should get an alert.
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gtz6v0yvklija9c9pafi.png)
- Add actions to activate alerts (e.g., add server log)
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5ym8w00z2prh0h5gmoiy.png)
- Logs dashboard and Triggered alerts 
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wm0nricqf4knqx49r9nj.png)
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/kq6hjswtegnr9f89ddcf.png)

## **Conclusion**

&amp;gt; We have successfully set up a Pritunl VPN server, integrated its logs with Filebeat and Elasticsearch, and configured alerts in Kibana. This setup provides comprehensive visibility into VPN activities and enables proactive monitoring through real-time alerts. 
Happy monitoring and secure VPN access!



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

&lt;/div&gt;

</description>
      <category>devops</category>
      <category>cloud</category>
      <category>security</category>
      <category>aws</category>
    </item>
  </channel>
</rss>
