<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Krishna Neupane]]></title><description><![CDATA[Learner]]></description><link>https://project.neupanekrishna.com.np</link><generator>RSS for Node</generator><lastBuildDate>Sun, 12 Apr 2026 19:14:13 GMT</lastBuildDate><atom:link href="https://project.neupanekrishna.com.np/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[How to Manage User Password Expiration and Aging in Linux]]></title><description><![CDATA[System administration involves numerous tasks, including managing users and groups and under-user management. Some of the minor tasks involved are adding, modifying, suspending, or deactivating user accounts, among many others.
This article will expl...]]></description><link>https://project.neupanekrishna.com.np/how-to-manage-user-password-expiration-and-aging-in-linux</link><guid isPermaLink="true">https://project.neupanekrishna.com.np/how-to-manage-user-password-expiration-and-aging-in-linux</guid><category><![CDATA[Linux]]></category><category><![CDATA[passwords]]></category><category><![CDATA[command line]]></category><dc:creator><![CDATA[Krishna Neupane]]></dc:creator><pubDate>Fri, 29 Dec 2023 13:32:52 GMT</pubDate><content:encoded><![CDATA[<p>System administration involves numerous tasks, including managing users and groups and under-user management. Some of the minor tasks involved are adding, modifying, suspending, or deactivating user accounts, among many others.</p>
<p>This article will explain one of the critical user account management functions: how to set or change user password expiration and aging in Linux using the <strong>change command</strong>.</p>
<p>The <strong>change command</strong> is used to modify user password expiration information. It enables you to view user account aging information and change the number of days between password changes and the date of the last password change.</p>
<p>Once you have set password expiry and aging information, this information is used by the system to determine when a user must change his or her password. Normally, companies or organizations have certain security policies that demand users change passwords regularly; this can be a simple way to enforce such policies as we explained below.</p>
<p>To view a user account aging information, use the <code>-l</code> flag as shown.</p>
<pre><code class="lang-plaintext"># chage -l ravi
</code></pre>
<p><img src="https://www.tecmint.com/wp-content/uploads/2018/02/view-user-password-aging-informatio.png" alt="View User Password Aging Information" /></p>
<p>View User Password Aging Information</p>
<p>To set the date or number of days (since <strong>January 1, 1970</strong>) when the password was last changed, use the <code>-d</code> flag as follows.</p>
<pre><code class="lang-plaintext"># chage -d 2018-02-11 ravi
</code></pre>
<p>Next, you can also set the date or number of days (since <strong>January 1, 1970</strong>) on which the user’s account will no longer be accessible by using the <code>-E</code> switch as shown in the following command.</p>
<p>In this case, once a user’s account is locked, he/she is required to contact the system administrator before being able to use the system again.</p>
<pre><code class="lang-plaintext"># chage -E 2018-02-16 ravi
</code></pre>
<p>Then, the <code>-W</code> option allows you to set the number of days of warning before a password change is required. Considering the command below, the user <strong>ravi</strong> will be warned <strong>10</strong> days before his password expires.</p>
<pre><code class="lang-plaintext"># chage -W 10 ravi
</code></pre>
<p>In addition, you can set the number of days of inactivity after a password has expired before the account is locked. This example means that after user ravi’s password expires, his account will be inactive for <strong>2</strong> days before it is locked.</p>
<p>When the account becomes inactive, he must contact the system administrator before being able to use the system again.</p>
<pre><code class="lang-plaintext"># chage -I 2 ravi
</code></pre>
<p>For more information, refer to the <strong>change man</strong> page.</p>
<pre><code class="lang-plaintext"># man chage
</code></pre>
<p>Note that you can also change a user’s password expiration and aging information using the <strong>usermod command</strong>, which is intended for modifying a user account.</p>
<p>That’s it for now. Hoping you find this article informative and useful.</p>
]]></content:encoded></item><item><title><![CDATA[Automatic Bitbucket Pipeline-To-Kubernetes]]></title><description><![CDATA[Automating the deployment process from Bitbucket Pipelines to Kubernetes involves setting up a continuous integration/continuous deployment (CI/CD) pipeline. Below is a general guide on how you can achieve this using Bitbucket Pipelines and Kubernete...]]></description><link>https://project.neupanekrishna.com.np/automatic-bitbucket-pipeline-to-kubernetes</link><guid isPermaLink="true">https://project.neupanekrishna.com.np/automatic-bitbucket-pipeline-to-kubernetes</guid><category><![CDATA[Bitbucket]]></category><category><![CDATA[Pipeline]]></category><category><![CDATA[Kubernetes]]></category><category><![CDATA[automation]]></category><category><![CDATA[bitbucket-pipelines]]></category><dc:creator><![CDATA[Krishna Neupane]]></dc:creator><pubDate>Thu, 28 Dec 2023 15:24:48 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1703776678218/52b275ed-599a-4228-bb4b-b414e5beb4c2.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Automating the deployment process from Bitbucket Pipelines to Kubernetes involves setting up a continuous integration/continuous deployment (CI/CD) pipeline. Below is a general guide on how you can achieve this using Bitbucket Pipelines and Kubernetes. This example assumes you are using AWS EKS for your Kubernetes cluster, but you can adjust the steps according to your specific setup.</p>
<p><strong>Prerequisites:</strong><br />1. <strong>Bitbucket Repository:</strong><br />Make sure you have your project hosted on Bitbucket.</p>
<p><strong>2. Kubernetes Cluster:</strong><br />Set up your Kubernetes cluster. This example assumes you are using AWS EKS.</p>
<p><a target="_blank" href="https://github.com/krishna-commits/automation-bitbucket-to-kubernetes-deployment">Code Link:</a> <a target="_blank" href="https://github.com/krishna-commits/automation-bitbucket-to-kubernetes-deployment">https://github.com/krishna-commits/automation-bitbucket-to-kubernetes-deployment</a></p>
<h2 id="heading-folder-structure"><strong>Folder Structure:</strong></h2>
<p><img src="https://miro.medium.com/v2/resize:fit:305/1*Hpevn2Eqwol18eMHiOI2lw.png" alt /></p>
<h1 id="heading-step-by-step-guide">Step-by-Step Guide:</h1>
<ol>
<li><strong>Configure Kubernetes Credentials in Bitbucket:</strong><br /> Set up environment variables in your Bitbucket repository settings (Settings &gt; Repository settings &gt; Pipeline &gt; Repository settings).</li>
</ol>
<pre><code class="lang-plaintext">AWS_ACCESS_KEY_ID
AWS_SECRET_ACCESS_KEY
AWS_DEFAULT_REGION
EKS_CLUSTER_NAME
ACCOUNT_ID
#Add other variable
</code></pre>
<p><strong>2. Define Bitbucket Pipelines:</strong><br />Set up your Bitbucket Pipelines configuration (bitbucket-pipelines.yml). Below is a simple example using Docker and Kubernetes for deployment:</p>
<pre><code class="lang-yaml"><span class="hljs-attr">image:</span> <span class="hljs-string">atlassian/pipelines-awscli</span>
<span class="hljs-attr">clone:</span>
  <span class="hljs-attr">depth:</span> <span class="hljs-string">full</span>
<span class="hljs-attr">options:</span>
  <span class="hljs-attr">size:</span> <span class="hljs-string">2x</span>
<span class="hljs-attr">pipelines:</span>
  <span class="hljs-attr">branches:</span>
    <span class="hljs-string">'*'</span><span class="hljs-string">:</span>
      <span class="hljs-bullet">-</span> <span class="hljs-attr">step:</span>
          <span class="hljs-attr">name:</span> <span class="hljs-string">Deploy</span> <span class="hljs-string">to</span> <span class="hljs-string">ECR</span> <span class="hljs-string">and</span> <span class="hljs-string">Selection</span> <span class="hljs-string">to</span> <span class="hljs-string">Branch</span>
          <span class="hljs-attr">services:</span>
            <span class="hljs-bullet">-</span> <span class="hljs-string">docker</span>
          <span class="hljs-attr">script:</span>
            <span class="hljs-bullet">-</span> <span class="hljs-string">echo</span> <span class="hljs-string">$BITBUCKET_BRANCH</span>
            <span class="hljs-bullet">-</span> <span class="hljs-string">apk</span> <span class="hljs-string">add</span> <span class="hljs-string">--no-cache</span> <span class="hljs-string">yq</span>
            <span class="hljs-bullet">-</span> <span class="hljs-string">DOMAIN=$(yq</span> <span class="hljs-string">eval</span> <span class="hljs-string">".branches[\"$BITBUCKET_BRANCH\"]"</span> <span class="hljs-string">k8s/staging/branch_domain_mapping.yml)</span>
            <span class="hljs-bullet">-</span> <span class="hljs-string">echo</span> <span class="hljs-string">$DOMAIN</span>
            <span class="hljs-bullet">-</span> <span class="hljs-string">|
              if [ "$BITBUCKET_BRANCH" != "production" ]; then
                  export AWS_ACCOUNT_ID=$ACCOUNT_ID
                  export AWS_ACCESS_KEY_ID=$AWS_ACCESS_KEY_ID
                  export AWS_SECRET_ACCESS_KEY=$AWS_SECRET_ACCESS_KEY
                  export AWS_DEFAULT_REGION=$AWS_DEFAULT_REGION
                  export K8S_CLUSTER=$K8S_CLUSTER
                else
                  export AWS_ACCOUNT_ID=$ACCOUNT_ID_PROD
                  export AWS_ACCESS_KEY_ID=$AWS_ACCESS_KEY_ID_PROD
                  export AWS_SECRET_ACCESS_KEY=$AWS_SECRET_ACCESS_KEY_PROD
                  export AWS_DEFAULT_REGION=$AWS_DEFAULT_REGION_PROD
                  export K8S_CLUSTER=$K8S_CLUSTER_PROD
                fi
</span>            <span class="hljs-bullet">-</span> <span class="hljs-string">export</span> <span class="hljs-string">APP=$(echo</span> <span class="hljs-string">$BITBUCKET_REPO_FULL_NAME-$BITBUCKET_BRANCH</span> <span class="hljs-string">|</span> <span class="hljs-string">awk</span> <span class="hljs-string">-F'/'</span> <span class="hljs-string">'{print tolower($2)}'</span><span class="hljs-string">)</span>
            <span class="hljs-bullet">-</span> <span class="hljs-string">export</span> <span class="hljs-string">BITBUCKET_COMMIT_SHORT=$(echo</span> <span class="hljs-string">$BITBUCKET_COMMIT</span> <span class="hljs-string">|</span> <span class="hljs-string">cut</span> <span class="hljs-string">-c1-7)</span>
            <span class="hljs-bullet">-</span> <span class="hljs-string">export</span> <span class="hljs-string">IMAGE_TAG=$BITBUCKET_COMMIT_SHORT</span> 
            <span class="hljs-bullet">-</span> <span class="hljs-string">export</span> <span class="hljs-string">DOCKER_REPO=$(echo</span> <span class="hljs-string">"$APP"</span> <span class="hljs-string">|</span> <span class="hljs-string">tr</span> <span class="hljs-string">'[:upper:]'</span> <span class="hljs-string">'[:lower:]'</span><span class="hljs-string">)</span> 
            <span class="hljs-bullet">-</span> <span class="hljs-string">export</span> <span class="hljs-string">IMAGE_URL=$(echo</span> <span class="hljs-string">$ACCOUNT_ID.dkr.ecr.$AWS_DEFAULT_REGION.amazonaws.com/$DOCKER_REPO:$IMAGE_TAG</span> <span class="hljs-string">|</span> <span class="hljs-string">awk</span> <span class="hljs-string">-F'/'</span> <span class="hljs-string">'{print tolower($2)}'</span><span class="hljs-string">)</span>
            <span class="hljs-bullet">-</span> <span class="hljs-string">pip</span> <span class="hljs-string">install</span> <span class="hljs-string">--upgrade</span> <span class="hljs-string">awscli</span>    
            <span class="hljs-bullet">-</span> <span class="hljs-string">|
              repository_exists=$(aws ecr describe-repositories --repository-names $APP --region $AWS_DEFAULT_REGION --output json | jq -r '.repositories | length')
</span>
              <span class="hljs-string">if</span> [ <span class="hljs-string">-z</span> <span class="hljs-string">"$repository_exists"</span> ]<span class="hljs-string">;</span> <span class="hljs-string">then</span>
                <span class="hljs-comment"># ECR repository does not exist, create it</span>
                <span class="hljs-string">echo</span> <span class="hljs-string">"Creating ECR repository: $APP"</span>
                <span class="hljs-string">aws</span> <span class="hljs-string">ecr</span> <span class="hljs-string">create-repository</span> <span class="hljs-string">--repository-name</span> <span class="hljs-string">$APP</span> <span class="hljs-string">--region</span> <span class="hljs-string">$AWS_DEFAULT_REGION</span> <span class="hljs-string">--image-tag-mutability</span> <span class="hljs-string">IMMUTABLE</span>
              <span class="hljs-string">fi</span>
            <span class="hljs-bullet">-</span> <span class="hljs-string">aws</span> <span class="hljs-string">ecr</span> <span class="hljs-string">get-login-password</span> <span class="hljs-string">--region</span> <span class="hljs-string">$AWS_DEFAULT_REGION</span> <span class="hljs-string">|</span> <span class="hljs-string">docker</span> <span class="hljs-string">login</span> <span class="hljs-string">--username</span> <span class="hljs-string">AWS</span> <span class="hljs-string">--password-stdin</span> <span class="hljs-string">$ACCOUNT_ID.dkr.ecr.$AWS_DEFAULT_REGION.amazonaws.com</span>
            <span class="hljs-bullet">-</span> <span class="hljs-string">IMAGE_URL=$ACCOUNT_ID.dkr.ecr.$AWS_DEFAULT_REGION.amazonaws.com/$DOCKER_REPO:$IMAGE_TAG</span>
            <span class="hljs-bullet">-</span> <span class="hljs-string">docker</span> <span class="hljs-string">build</span> <span class="hljs-string">-t</span> <span class="hljs-string">"$IMAGE_URL"</span> <span class="hljs-string">.</span>
            <span class="hljs-bullet">-</span> <span class="hljs-string">docker</span> <span class="hljs-string">tag</span> <span class="hljs-string">"$IMAGE_URL"</span> <span class="hljs-string">"$IMAGE_URL"</span>
            <span class="hljs-bullet">-</span> <span class="hljs-string">docker</span> <span class="hljs-string">push</span> <span class="hljs-string">"$IMAGE_URL"</span>
          <span class="hljs-attr">variables:</span>
            <span class="hljs-attr">IMAGE_URL:</span> <span class="hljs-string">$ACCOUNT_ID.dkr.ecr.$AWS_DEFAULT_REGION.amazonaws.com/$DOCKER_REPO:$IMAGE_TAG</span>
            <span class="hljs-attr">DOMAIN:</span> <span class="hljs-string">$DOMAIN</span>
      <span class="hljs-bullet">-</span> <span class="hljs-attr">step:</span>
          <span class="hljs-attr">name:</span> <span class="hljs-string">Deploy</span> <span class="hljs-string">to</span> <span class="hljs-string">Kubernetes</span>
          <span class="hljs-attr">script:</span>
            <span class="hljs-bullet">-</span> <span class="hljs-string">wget</span> <span class="hljs-string">-O</span> <span class="hljs-string">kubectl</span> <span class="hljs-string">"https://dl.k8s.io/release/$(wget -qO- https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"</span>
            <span class="hljs-bullet">-</span> <span class="hljs-string">chmod</span> <span class="hljs-string">+x</span> <span class="hljs-string">kubectl</span>  
            <span class="hljs-bullet">-</span> <span class="hljs-string">mv</span> <span class="hljs-string">kubectl</span> <span class="hljs-string">/usr/local/bin/</span> 
            <span class="hljs-bullet">-</span> <span class="hljs-string">kubectl</span> <span class="hljs-string">version</span> <span class="hljs-string">--client</span>  
            <span class="hljs-bullet">-</span> <span class="hljs-string">apk</span> <span class="hljs-string">add</span> <span class="hljs-string">--no-cache</span> <span class="hljs-string">yq</span>
            <span class="hljs-bullet">-</span> <span class="hljs-string">DOMAIN=$(yq</span> <span class="hljs-string">eval</span> <span class="hljs-string">".branches[\"$BITBUCKET_BRANCH\"]"</span> <span class="hljs-string">k8s/staging/branch_domain_mapping.yml)</span>
            <span class="hljs-bullet">-</span> <span class="hljs-string">export</span> <span class="hljs-string">ACCOUNT_ID=$ACCOUNT_ID</span>
            <span class="hljs-bullet">-</span> <span class="hljs-string">export</span> <span class="hljs-string">AWS_ACCESS_KEY_ID=$AWS_ACCESS_KEY_ID</span>
            <span class="hljs-bullet">-</span> <span class="hljs-string">export</span> <span class="hljs-string">AWS_SECRET_ACCESS_KEY=$AWS_SECRET_ACCESS_KEY</span>
            <span class="hljs-bullet">-</span> <span class="hljs-string">export</span> <span class="hljs-string">AWS_DEFAULT_REGION=$AWS_DEFAULT_REGION</span>
            <span class="hljs-bullet">-</span> <span class="hljs-string">export</span> <span class="hljs-string">K8S_CLUSTER=$K8S_CLUSTER</span>
            <span class="hljs-bullet">-</span> <span class="hljs-string">export</span> <span class="hljs-string">BITBUCKET_COMMIT_SHORT=$(echo</span> <span class="hljs-string">$BITBUCKET_COMMIT</span> <span class="hljs-string">|</span> <span class="hljs-string">cut</span> <span class="hljs-string">-c1-7)</span>
            <span class="hljs-bullet">-</span> <span class="hljs-string">export</span> <span class="hljs-string">IMAGE_TAG=$BITBUCKET_COMMIT_SHORT</span> 
            <span class="hljs-bullet">-</span> <span class="hljs-string">echo</span> <span class="hljs-string">$IMAGE_TAG</span>
            <span class="hljs-bullet">-</span> <span class="hljs-string">export</span> <span class="hljs-string">DOMAIN=$DOMAIN</span>
            <span class="hljs-bullet">-</span> <span class="hljs-string">aws</span> <span class="hljs-string">configure</span> <span class="hljs-string">set</span> <span class="hljs-string">aws_access_key_id</span> <span class="hljs-string">"${AWS_ACCESS_KEY_ID}"</span>
            <span class="hljs-bullet">-</span> <span class="hljs-string">aws</span> <span class="hljs-string">configure</span> <span class="hljs-string">set</span> <span class="hljs-string">aws_secret_access_key</span> <span class="hljs-string">"${AWS_SECRET_ACCESS_KEY}"</span>
            <span class="hljs-bullet">-</span> <span class="hljs-string">aws</span> <span class="hljs-string">eks</span> <span class="hljs-string">--region</span> <span class="hljs-string">$AWS_DEFAULT_REGION</span> <span class="hljs-string">update-kubeconfig</span> <span class="hljs-string">--name</span> <span class="hljs-string">$K8S_CLUSTER</span>
            <span class="hljs-bullet">-</span> <span class="hljs-string">export</span> <span class="hljs-string">APP=$(echo</span> <span class="hljs-string">$BITBUCKET_REPO_FULL_NAME-$BITBUCKET_BRANCH</span> <span class="hljs-string">|</span> <span class="hljs-string">awk</span> <span class="hljs-string">-F'/'</span> <span class="hljs-string">'{print tolower($2)}'</span><span class="hljs-string">)</span>
            <span class="hljs-bullet">-</span> <span class="hljs-string">export</span> <span class="hljs-string">DOCKER_REPO=$(echo</span> <span class="hljs-string">"$APP"</span> <span class="hljs-string">|</span> <span class="hljs-string">tr</span> <span class="hljs-string">'[:upper:]'</span> <span class="hljs-string">'[:lower:]'</span><span class="hljs-string">)</span> 
            <span class="hljs-bullet">-</span> <span class="hljs-string">|
              namespace_exists=$(kubectl get namespace "$APP" --ignore-not-found=true -o jsonpath='{.metadata.name}')
</span>
              <span class="hljs-string">if</span> [ <span class="hljs-string">-z</span> <span class="hljs-string">"$namespace_exists"</span> ]<span class="hljs-string">;</span> <span class="hljs-string">then</span>
                <span class="hljs-comment"># Namespace does not exist, create it</span>
                <span class="hljs-string">echo</span> <span class="hljs-string">"Creating Kubernetes namespace: $APP"</span>
                <span class="hljs-string">kubectl</span> <span class="hljs-string">create</span> <span class="hljs-string">namespace</span> <span class="hljs-string">"$APP"</span>
              <span class="hljs-string">fi</span>

            <span class="hljs-bullet">-</span> <span class="hljs-string">export</span> <span class="hljs-string">IMAGE_URL="$ACCOUNT_ID.dkr.ecr.$AWS_DEFAULT_REGION.amazonaws.com/$DOCKER_REPO:$IMAGE_TAG"</span>
            <span class="hljs-bullet">-</span> <span class="hljs-string">sed</span> <span class="hljs-string">-i</span> <span class="hljs-string">'s/<span class="hljs-template-variable">{{APP}}</span>/'</span><span class="hljs-string">"$APP"</span><span class="hljs-string">'/g'</span> <span class="hljs-string">k8s/staging/deployment.yaml</span>
            <span class="hljs-bullet">-</span> <span class="hljs-string">sed</span> <span class="hljs-string">-i</span> <span class="hljs-string">'s~<span class="hljs-template-variable">{{IMAGE_URL}}</span>~'</span><span class="hljs-string">"$IMAGE_URL"</span><span class="hljs-string">'~'</span> <span class="hljs-string">k8s/staging/deployment.yaml</span>
            <span class="hljs-bullet">-</span> <span class="hljs-string">sed</span> <span class="hljs-string">-i</span> <span class="hljs-string">'s/<span class="hljs-template-variable">{{DOMAIN}}</span>/'</span><span class="hljs-string">"$DOMAIN"</span><span class="hljs-string">'/g'</span> <span class="hljs-string">k8s/staging/deployment.yaml</span>
            <span class="hljs-bullet">-</span> <span class="hljs-string">cat</span> <span class="hljs-string">k8s/staging/deployment.yaml</span> 
            <span class="hljs-bullet">-</span> <span class="hljs-string">|
              if ! kubectl get deployment "${APP}-deployment" --namespace="${APP}" &amp;&gt; /dev/null; then
                echo "Deploying initial Kubernetes resources..."
                kubectl apply -f k8s/staging/deployment.yaml --namespace="${APP}"
              else
                echo "Restarting deployment..."
                kubectl apply -f k8s/staging/deployment.yaml --namespace="${APP}"
                kubectl rollout restart deployment "${APP}-deployment" --namespace="${APP}"
              fi
</span>            <span class="hljs-bullet">-</span> <span class="hljs-string">echo</span> <span class="hljs-string">$DOMAIN</span>
<span class="hljs-attr">definitions:</span>
  <span class="hljs-attr">services:</span>
    <span class="hljs-attr">docker:</span>
      <span class="hljs-attr">memory:</span> <span class="hljs-number">7168</span>
</code></pre>
<p>This pipeline builds and pushes a Docker image to ECR, then deploys the Kubernetes manifests in the <code>k8s/</code> directory.</p>
<p><strong>3. Cert-manager:<br /><em>Note: If you don’t have any certificate you can used this step. This Cert-Manager is Code for the Kubernetes Cluster , If you have already Cert-manager install on the Kubernetes Cluster, Skipped this point 3.</em></strong></p>
<p>Cert-manager is a <strong>Kubernetes tool</strong> that issues certificates from various certificate providers, including Let’s Encrypt.</p>
<p><strong>To install cert-manager using helm:</strong></p>
<p><strong>Step 1: Install the Custom Resource Definition resources.</strong></p>
<pre><code class="lang-plaintext">$ kubectl apply --validate=false \-f https://github.com/jetstack/cert-manager/releases/download/v1.5.3/cert-manager.yaml
</code></pre>
<p><strong><em>Note: Currently I am using 1.5.3 Version of Jetstack cert manager</em></strong></p>
<p>Step 2: Create a namespace for cert-manager</p>
<pre><code class="lang-plaintext">$ kubectl create ns cert-manager
</code></pre>
<p>Step 3. Add the Jetstack Helm repository and update your local Helm chart repo cache.</p>
<pre><code class="lang-plaintext">$ helm repo add jetstack https://charts.jetstack.io
$ helm repo update
</code></pre>
<p>Step 4. Install the cert-manager Helm chart</p>
<pre><code class="lang-plaintext">$ helm install --name cert-manager --namespace cert-manager --version v1.5.3 jetstack\cert-manager
</code></pre>
<p>Now verify the installation:</p>
<pre><code class="lang-plaintext">$ kubectl get pods --namespace cert-manager
NAME                                       
cert-manager-66b6d6bf59-tmlgw
cert-manager-cainjector-856d4df858-z4k5s
cert-manager-webhook-5fd7d458f7-zwbnc
</code></pre>
<p>The certificates provided by Let’s Encrypt are valid for 90 days at no charge, and you can renewal at any time.</p>
<p>The certificate generation and renewal can be automated using cert-bot and cert-manager (for k8's).</p>
<p><strong>4. Kubernetes Manifests:</strong></p>
<p>Organize Kubernetes deployment manifests (<code>k8s/</code>). Adjust these files based on your application and requirements.<br /><em>In this Deployment.yaml file it Contain Deployment, Service, Certificate Issuer and Ingress. You can make the different file for different Kind.</em></p>
<pre><code class="lang-yaml"><span class="hljs-attr">apiVersion:</span> <span class="hljs-string">apps/v1</span>
<span class="hljs-attr">kind:</span> <span class="hljs-string">Deployment</span>
<span class="hljs-attr">metadata:</span>
  <span class="hljs-attr">name:</span> {{<span class="hljs-string">APP</span>}}<span class="hljs-string">-deployment</span>
  <span class="hljs-attr">labels:</span>
    <span class="hljs-attr">app:</span> {{<span class="hljs-string">APP</span>}}
<span class="hljs-attr">spec:</span>
  <span class="hljs-attr">replicas:</span> <span class="hljs-number">1</span>
  <span class="hljs-attr">selector:</span>
    <span class="hljs-attr">matchLabels:</span>
      <span class="hljs-attr">app:</span> {{<span class="hljs-string">APP</span>}}
  <span class="hljs-attr">template:</span>
    <span class="hljs-attr">metadata:</span>
      <span class="hljs-attr">labels:</span>
        <span class="hljs-attr">app:</span> {{<span class="hljs-string">APP</span>}}
    <span class="hljs-attr">spec:</span>
      <span class="hljs-attr">containers:</span>
        <span class="hljs-bullet">-</span> <span class="hljs-attr">name:</span> {{<span class="hljs-string">APP</span>}}
          <span class="hljs-attr">image:</span> {{<span class="hljs-string">IMAGE_URL</span>}}
          <span class="hljs-attr">ports:</span>
            <span class="hljs-bullet">-</span> <span class="hljs-attr">containerPort:</span> <span class="hljs-number">80</span>
<span class="hljs-meta">---</span>
<span class="hljs-attr">apiVersion:</span> <span class="hljs-string">v1</span>
<span class="hljs-attr">kind:</span> <span class="hljs-string">Service</span>
<span class="hljs-attr">metadata:</span>
  <span class="hljs-attr">name:</span> {{<span class="hljs-string">APP</span>}}<span class="hljs-string">-service</span>
<span class="hljs-attr">spec:</span>
  <span class="hljs-attr">ports:</span>
    <span class="hljs-bullet">-</span> <span class="hljs-attr">name:</span> <span class="hljs-string">http</span>
      <span class="hljs-attr">protocol:</span> <span class="hljs-string">TCP</span>
      <span class="hljs-attr">port:</span> <span class="hljs-number">80</span>
      <span class="hljs-attr">targetPort:</span> <span class="hljs-number">80</span>
  <span class="hljs-attr">selector:</span>
    <span class="hljs-attr">app:</span> {{<span class="hljs-string">APP</span>}}
  <span class="hljs-attr">type:</span> <span class="hljs-string">ClusterIP</span>
<span class="hljs-meta">---</span>
<span class="hljs-attr">apiVersion:</span> <span class="hljs-string">cert-manager.io/v1</span>
<span class="hljs-attr">kind:</span> <span class="hljs-string">Issuer</span>
<span class="hljs-attr">metadata:</span>
  <span class="hljs-attr">name:</span> <span class="hljs-string">letsencrypt-prod</span>
<span class="hljs-attr">spec:</span>
  <span class="hljs-attr">acme:</span>
    <span class="hljs-attr">server:</span> <span class="hljs-string">https://acme-v02.api.letsencrypt.org/directory</span>
    <span class="hljs-attr">email:</span> <span class="hljs-string">neupane.krishna33@gmail.com</span>
    <span class="hljs-attr">privateKeySecretRef:</span>
      <span class="hljs-attr">name:</span> <span class="hljs-string">letsencrypt-prod</span>
    <span class="hljs-attr">solvers:</span>
      <span class="hljs-bullet">-</span> <span class="hljs-attr">http01:</span>
          <span class="hljs-attr">ingress:</span>
            <span class="hljs-attr">class:</span> <span class="hljs-string">nginx</span>
<span class="hljs-meta">---</span>
<span class="hljs-attr">apiVersion:</span> <span class="hljs-string">networking.k8s.io/v1</span>
<span class="hljs-attr">kind:</span> <span class="hljs-string">Ingress</span>
<span class="hljs-attr">metadata:</span>
  <span class="hljs-attr">name:</span> {{<span class="hljs-string">APP</span>}}<span class="hljs-string">-ingress</span>
  <span class="hljs-attr">labels:</span>
    <span class="hljs-attr">app:</span> {{<span class="hljs-string">APP</span>}}
  <span class="hljs-attr">annotations:</span>
    <span class="hljs-attr">cert-manager.io/cluster-issuer:</span> <span class="hljs-string">letsencrypt-prod</span>
    <span class="hljs-attr">kubernetes.io/ingress.class:</span> <span class="hljs-string">nginx</span>
<span class="hljs-attr">spec:</span>
  <span class="hljs-attr">tls:</span>
    <span class="hljs-bullet">-</span> <span class="hljs-attr">hosts:</span>
        <span class="hljs-bullet">-</span> {{<span class="hljs-string">DOMAIN</span>}}
      <span class="hljs-attr">secretName:</span> {{<span class="hljs-string">APP</span>}}<span class="hljs-string">-tls</span>
  <span class="hljs-attr">rules:</span>
    <span class="hljs-bullet">-</span> <span class="hljs-attr">host:</span> {{<span class="hljs-string">DOMAIN</span>}}
      <span class="hljs-attr">http:</span>
        <span class="hljs-attr">paths:</span>
          <span class="hljs-bullet">-</span> <span class="hljs-attr">path:</span> <span class="hljs-string">/</span>
            <span class="hljs-attr">pathType:</span> <span class="hljs-string">Prefix</span>
            <span class="hljs-attr">backend:</span>
              <span class="hljs-attr">service:</span>
                <span class="hljs-attr">name:</span> {{<span class="hljs-string">APP</span>}}<span class="hljs-string">-service</span>
                <span class="hljs-attr">port:</span>
                  <span class="hljs-attr">number:</span> <span class="hljs-number">80</span>
</code></pre>
<p><strong>Note</strong>: Provide a valid email address. You will receive <strong>email notifications</strong> on certificate renewals.</p>
<p><strong>Breakdown the above code:</strong></p>
<p>Below set of YAML manifests is designed to deploy an application to Kubernetes, expose it via a <strong>Service</strong>, configure <strong>TLS</strong> using Let’s Encrypt through <strong>cert-manager</strong>, and define Ingress rules for routing traffic.<br /><strong>Deployment and Service:  
</strong>Defines the deployment of your application with one replica and a corresponding service.<br /><strong>Cert-Manager Issuer:  
</strong>Configures the issuer for Let’s Encrypt to obtain TLS certificates.<br /><strong>Ingress:  
</strong>Specifies the Ingress resource with TLS configuration, rules for routing, and annotations for cert-manager and Ingress class.</p>
<p><strong>Deployment</strong></p>
<pre><code class="lang-yaml"><span class="hljs-attr">apiVersion:</span> <span class="hljs-string">apps/v1</span>
<span class="hljs-attr">kind:</span> <span class="hljs-string">Deployment</span>
<span class="hljs-attr">metadata:</span>
  <span class="hljs-attr">name:</span> {{<span class="hljs-string">APP</span>}}<span class="hljs-string">-deployment</span>
  <span class="hljs-attr">labels:</span>
    <span class="hljs-attr">app:</span> {{<span class="hljs-string">APP</span>}}
<span class="hljs-attr">spec:</span>
  <span class="hljs-attr">replicas:</span> <span class="hljs-number">1</span>
  <span class="hljs-attr">selector:</span>
    <span class="hljs-attr">matchLabels:</span>
      <span class="hljs-attr">app:</span> {{<span class="hljs-string">APP</span>}}
  <span class="hljs-attr">template:</span>
    <span class="hljs-attr">metadata:</span>
      <span class="hljs-attr">labels:</span>
        <span class="hljs-attr">app:</span> {{<span class="hljs-string">APP</span>}}
    <span class="hljs-attr">spec:</span>
      <span class="hljs-attr">containers:</span>
        <span class="hljs-bullet">-</span> <span class="hljs-attr">name:</span> {{<span class="hljs-string">APP</span>}}
          <span class="hljs-attr">image:</span> {{<span class="hljs-string">IMAGE_URL</span>}}
          <span class="hljs-attr">ports:</span>
            <span class="hljs-bullet">-</span> <span class="hljs-attr">containerPort:</span> <span class="hljs-number">80</span>
</code></pre>
<pre><code class="lang-plaintext">##what each line does:

apiVersion and kind:
Specifies the API version and kind of the Kubernetes resource. In this case, it's a Deployment in the apps/v1 API version.

metadata:
name: The name of the Deployment is set to {{APP}}-deployment.
labels: Labels are used to identify and organize resources. The app label is set to {{APP}}.

spec:
replicas: Defines the desired number of replicas for the pods managed by this Deployment. In this case, it's set to 1.
selector: Specifies how the Deployment identifies which pods to manage. It matches pods with the app: {{APP}} label.
template: Describes the pod template used to create new pods.
metadata: Specifies labels for the pods.
spec: Defines the pod specification, including the container.
containers: Describes the containers within the pod.
name: The name of the container is set to {{APP}}.
image: Specifies the Docker image for the container, set to {{IMAGE_URL}}.
ports: Specifies the ports the container exposes.
</code></pre>
<p><strong>Service:</strong></p>
<pre><code class="lang-yaml"><span class="hljs-attr">apiVersion:</span> <span class="hljs-string">v1</span>
<span class="hljs-attr">kind:</span> <span class="hljs-string">Service</span>
<span class="hljs-attr">metadata:</span>
  <span class="hljs-attr">name:</span> {{<span class="hljs-string">APP</span>}}<span class="hljs-string">-service</span>
<span class="hljs-attr">spec:</span>
  <span class="hljs-attr">ports:</span>
    <span class="hljs-bullet">-</span> <span class="hljs-attr">name:</span> <span class="hljs-string">http</span>
      <span class="hljs-attr">protocol:</span> <span class="hljs-string">TCP</span>
      <span class="hljs-attr">port:</span> <span class="hljs-number">80</span>
      <span class="hljs-attr">targetPort:</span> <span class="hljs-number">80</span>
  <span class="hljs-attr">selector:</span>
    <span class="hljs-attr">app:</span> {{<span class="hljs-string">APP</span>}}
  <span class="hljs-attr">type:</span> <span class="hljs-string">ClusterIP</span>
</code></pre>
<pre><code class="lang-plaintext">##what each line does:
apiVersion and kind:
Specifies the API version and kind of the Kubernetes resource. In this case, it's a Service in the v1 API version.

metadata:
name: The name of the Service is set to {{APP}}-service.

spec:
ports: Defines the ports that the Service exposes.
name: The name of the port is set to http.
protocol: Specifies the protocol as TCP.
port: The port on which the Service is exposed externally is set to 80.
targetPort: Specifies the port to which traffic is forwarded, set to 80.
selector: Matches pods with the app: {{APP}} label.
type: Specifies the type of Service. In this case, it's set to ClusterIP.
</code></pre>
<h2 id="heading-cert-manager-issuer">Cert-Manager Issuer:</h2>
<pre><code class="lang-yaml"><span class="hljs-attr">apiVersion:</span> <span class="hljs-string">cert-manager.io/v1</span>
<span class="hljs-attr">kind:</span> <span class="hljs-string">Issuer</span>
<span class="hljs-attr">metadata:</span>
  <span class="hljs-attr">name:</span> <span class="hljs-string">letsencrypt-prod</span>
<span class="hljs-attr">spec:</span>
  <span class="hljs-attr">acme:</span>
    <span class="hljs-attr">server:</span> <span class="hljs-string">https://acme-v02.api.letsencrypt.org/directory</span>
    <span class="hljs-attr">email:</span> <span class="hljs-string">neupane.krishna33@gmail.com</span>
    <span class="hljs-attr">privateKeySecretRef:</span>
      <span class="hljs-attr">name:</span> <span class="hljs-string">letsencrypt-prod</span>
    <span class="hljs-attr">solvers:</span>
      <span class="hljs-bullet">-</span> <span class="hljs-attr">http01:</span>
          <span class="hljs-attr">ingress:</span>
            <span class="hljs-attr">class:</span> <span class="hljs-string">nginx</span>
</code></pre>
<pre><code class="lang-plaintext">##what each line does:

apiVersion and kind:
Specifies the API version and kind of the Kubernetes resource. In this case, it's an Issuer in the cert-manager.io/v1 API version.

metadata:
name: The name of the Issuer is set to letsencrypt-prod.

spec:
acme: Configures the issuer for the ACME protocol used by Let's Encrypt.
server: The ACME server URL.
email: The email address for the Let's Encrypt account.
privateKeySecretRef: The secret that contains the private key.
solvers: Configures the challenges used for validation. In this case, it's HTTP01.
</code></pre>
<h1 id="heading-ingress">Ingress:</h1>
<pre><code class="lang-yaml"><span class="hljs-attr">apiVersion:</span> <span class="hljs-string">networking.k8s.io/v1</span>
<span class="hljs-attr">kind:</span> <span class="hljs-string">Ingress</span>
<span class="hljs-attr">metadata:</span>
  <span class="hljs-attr">name:</span> {{<span class="hljs-string">APP</span>}}<span class="hljs-string">-ingress</span>
  <span class="hljs-attr">labels:</span>
    <span class="hljs-attr">app:</span> {{<span class="hljs-string">APP</span>}}
  <span class="hljs-attr">annotations:</span>
    <span class="hljs-attr">cert-manager.io/cluster-issuer:</span> <span class="hljs-string">letsencrypt-prod</span>
    <span class="hljs-attr">kubernetes.io/ingress.class:</span> <span class="hljs-string">nginx</span>
<span class="hljs-attr">spec:</span>
  <span class="hljs-attr">tls:</span>
    <span class="hljs-bullet">-</span> <span class="hljs-attr">hosts:</span>
        <span class="hljs-bullet">-</span> {{<span class="hljs-string">DOMAIN</span>}}
      <span class="hljs-attr">secretName:</span> {{<span class="hljs-string">APP</span>}}<span class="hljs-string">-tls</span>
  <span class="hljs-attr">rules:</span>
    <span class="hljs-bullet">-</span> <span class="hljs-attr">host:</span> {{<span class="hljs-string">DOMAIN</span>}}
      <span class="hljs-attr">http:</span>
        <span class="hljs-attr">paths:</span>
          <span class="hljs-bullet">-</span> <span class="hljs-attr">path:</span> <span class="hljs-string">/</span>
            <span class="hljs-attr">pathType:</span> <span class="hljs-string">Prefix</span>
            <span class="hljs-attr">backend:</span>
              <span class="hljs-attr">service:</span>
                <span class="hljs-attr">name:</span> {{<span class="hljs-string">APP</span>}}<span class="hljs-string">-service</span>
                <span class="hljs-attr">port:</span>
                  <span class="hljs-attr">number:</span> <span class="hljs-number">80</span>
</code></pre>
<pre><code class="lang-plaintext">##what each line does:

apiVersion and kind:
Specifies the API version and kind of the Kubernetes resource. In this case, it's an Ingress in the networking.k8s.io/v1 API version.

metadata:
name: The name of the Ingress is set to {{APP}}-ingress.
labels: Labels are used to identify and organize resources. The app label is set to {{APP}}.

annotations:
Annotations provide additional configuration. In this case:
cert-manager.io/cluster-issuer: Specifies the cluster issuer for TLS certificates.
kubernetes.io/ingress.class: Specifies the Ingress class.

spec:
tls: Configures TLS for the Ingress.
hosts: Specifies the hosts for which TLS certificates should be issued.
secretName: Specifies the name of the secret where the TLS certificate is stored.
rules: Defines routing rules based on the host.
host: Specifies the domain for which the Ingress rules apply.
http: Configures HTTP routing rules.
paths: Defines paths and their corresponding backends.
path: Specifies the path for the rule.
backend: Specifies the backend service.
</code></pre>
<p><strong>5. Branch wise Domain Mapping:  
</strong>Currently, Here i used static way to map domain using bitbucket branches , but we can passed the values using the dynamic ways</p>
<p><strong>branch_domain_mapping.yml</strong></p>
<pre><code class="lang-yaml"><span class="hljs-attr">branches:</span>
  <span class="hljs-attr">master:</span> <span class="hljs-string">neupanekrishna.com.np</span>
  <span class="hljs-attr">dev:</span> <span class="hljs-string">neupanekrishna.com.np</span>
  <span class="hljs-attr">staging:</span> <span class="hljs-string">neupanekrishna.com.np</span>
  <span class="hljs-attr">production:</span> <span class="hljs-string">neupanekrishna.com.np</span>
  <span class="hljs-attr">feature_branch_1:</span> <span class="hljs-string">custom1</span>
  <span class="hljs-attr">feature_branch_2:</span> <span class="hljs-string">custom2</span>
  <span class="hljs-comment"># ... add mappings for all branches</span>
</code></pre>
<pre><code class="lang-plaintext">##what each line does:

branches:: This is the key indicating the start of the branch mappings section.

master: neupanekrishna.com.np: For the master branch, the associated domain is set to neupanekrishna.com.np. This means that when you are on the master branch, the pipeline will deploy to the domain neupanekrishna.com.np.
dev: neupanekrishna.com.np: Similarly, for the dev branch, the associated domain is set to neupanekrishna.com.np.
staging: neupanekrishna.com.np: The staging branch also maps to the same domain.
production: neupanekrishna.com.np: The production branch maps to the same domain.
feature_branch_1: custom1: For the feature_branch_1 branch, the associated domain is set to custom1. This allows you to have a different domain for this specific feature branch.
feature_branch_2: custom2: Similarly, for the feature_branch_2 branch, the associated domain is set to custom2.
</code></pre>
<p><strong>6. Execute Pipelines:</strong><br />Push changes to your repository, and Bitbucket Pipelines will automatically trigger the pipeline. Monitor the pipeline execution in the Bitbucket Pipelines dashboard.</p>
]]></content:encoded></item><item><title><![CDATA[How to centralize logs with rsyslog logstash elasticsearch and kibana on Ubuntu 20.04]]></title><description><![CDATA[To install Elasticsearch on Ubuntu 20.04, follow these steps:
sudo apt update
sudo apt install openjdk-11-jre-headless
wget -qO - https://artifacts.elastic.co/GPG-KEY-elasticsearch | sudo apt-key add -
sudo sh -c 'echo "deb https://artifacts.elastic....]]></description><link>https://project.neupanekrishna.com.np/how-to-centralize-logs-with-rsyslog-logstash-elasticsearch-and-kibana-on-ubuntu-2004</link><guid isPermaLink="true">https://project.neupanekrishna.com.np/how-to-centralize-logs-with-rsyslog-logstash-elasticsearch-and-kibana-on-ubuntu-2004</guid><category><![CDATA[kibana]]></category><category><![CDATA[rsyslog]]></category><category><![CDATA[logstash]]></category><category><![CDATA[elasticsearch]]></category><category><![CDATA[Ubuntu 20.04]]></category><dc:creator><![CDATA[Krishna Neupane]]></dc:creator><pubDate>Thu, 28 Dec 2023 14:38:55 GMT</pubDate><content:encoded><![CDATA[<p><strong>To install Elasticsearch on Ubuntu 20.04, follow these steps:</strong></p>
<pre><code class="lang-plaintext">sudo apt update
sudo apt install openjdk-11-jre-headless
wget -qO - https://artifacts.elastic.co/GPG-KEY-elasticsearch | sudo apt-key add -
sudo sh -c 'echo "deb https://artifacts.elastic.co/packages/7.x/apt stable main" &gt; /etc/apt/sources.list.d/elastic-7.x.list'
sudo apt install elasticsearch
sudo service elasticsearch start
sudo systemctl enable elasticsearch
</code></pre>
<p><strong>Test Elasticsearch:</strong></p>
<p>Verify that Elasticsearch is up and running.</p>
<pre><code class="lang-plaintext">curl -X GET "localhost:9200/"
</code></pre>
<p><strong>Install Logstash:</strong></p>
<pre><code class="lang-plaintext">sudo apt update
sudo apt install openjdk-11-jre-headless
wget -qO - https://artifacts.elastic.co/GPG-KEY-elasticsearch | sudo apt-key add -
sudo sh -c 'echo "deb https://artifacts.elastic.co/packages/7.x/apt stable main" &gt; /etc/apt/sources.list.d/elastic-7.x.list'
sudo apt update
sudo apt install logstash
</code></pre>
<p>Now <strong>Install Rsyslog on Ubuntu</strong></p>
<pre><code class="lang-plaintext">apt list -a rsyslog
sudo systemctl enable --now rsyslog
</code></pre>
<p><strong>Configure rsyslog:</strong></p>
<p>rsyslog configuration (<code>/etc/rsyslog.conf</code> or <code>/etc/rsyslog.d/your-config-file.conf</code>):</p>
<pre><code class="lang-plaintext"># Load the imuxsock module for local log reception
$ModLoad imuxsock

# Send messages to Logstash
*.* action(type="omfwd" target="logstash_server_ip" port="514" protocol="tcp")
</code></pre>
<p><strong>Restart Services:</strong></p>
<pre><code class="lang-plaintext">sudo service rsyslog restart
</code></pre>
<p><strong>Configure Logstash for rsyslog:</strong></p>
<p>Create a Logstash configuration file for rsyslog by creating a new file (e.g., <code>/etc/logstash/conf.d/10-rsyslog.conf</code>) with the following content:</p>
<pre><code class="lang-plaintext">input {
  tcp {
    port =&gt; 514
    type =&gt; syslog
  }
  udp {
    port =&gt; 514
    type =&gt; syslog
  }
}

filter {
  if [type] == "syslog" {
    grok {
      match =&gt; { "message" =&gt; "%{SYSLOGTIMESTAMP:syslog_timestamp} %{SYSLOGHOST:syslog_hostname} %{DATA:syslog_program}(?:\[%{POSINT:syslog_pid}\])?: %{GREEDYDATA:syslog_message}" }
      add_field =&gt; [ "received_at", "%{@timestamp}" ]
      add_field =&gt; [ "received_from", "%{host}" ]
    }
    date {
      match =&gt; [ "syslog_timestamp", "MMM  d HH:mm:ss", "MMM dd HH:mm:ss" ]
    }
  }
}

output {
  elasticsearch {
    hosts =&gt; ["localhost:9200"]
    index =&gt; "rsyslog-%{+YYYY.MM.dd}"
  }
}
</code></pre>
<p><strong>Note: If the 514 port will not work or give an error use higher port 5514</strong></p>
<pre><code class="lang-plaintext">input {
  tcp {
    port =&gt; 5514
    type =&gt; "syslog"
  }
}
</code></pre>
<p><strong>Restart Logstash:</strong></p>
<pre><code class="lang-plaintext">sudo service logstash restart
</code></pre>
<p><strong>Install and Configure Kibana:</strong></p>
<pre><code class="lang-plaintext">sudo apt update
sudo apt install kibana
sudo service kibana start
</code></pre>
<p>If you’re unsure about the correct service name, you can list available services:</p>
<pre><code class="lang-plaintext">sudo service --status-all
</code></pre>
<p>Check Systemd Status:</p>
<pre><code class="lang-plaintext">systemctl status kibana
</code></pre>
<p>If it’s not recognized, you might need to reload the <code>systemd</code> daemon or manually enable the service:</p>
<pre><code class="lang-plaintext">sudo systemctl daemon-reload
sudo systemctl enable kibana
</code></pre>
<p><strong>Check Kibana Configuration:</strong></p>
<p>Verify that Kibana is configured to listen on all network interfaces (<code>0.0.0.0</code>) so that it can accept connections from external machines. Open the Kibana configuration file (<code>/etc/kibana/kibana.yml</code>) and ensure that the <a target="_blank" href="http://server.host"><code>server.host</code></a> option is set to:</p>
<pre><code class="lang-plaintext">server.host: "0.0.0.0"
</code></pre>
<p><strong>Verify Elasticsearch Connection:</strong></p>
<p>Kibana requires a functional connection to Elasticsearch. Ensure that Elasticsearch is running and properly configured. Verify that the Elasticsearch URL is correctly set in the Kibana configuration file (<code>/etc/kibana/kibana.yml</code>):</p>
<pre><code class="lang-plaintext">elasticsearch.hosts: ["http://localhost:9200"]
</code></pre>
<p>After making changes, restart the Kibana service:</p>
<pre><code class="lang-plaintext">sudo service kibana restart
</code></pre>
<p><strong>Access via Browser:</strong></p>
<pre><code class="lang-plaintext">http://kibana-server-ip:5601
</code></pre>
<p>Remember that this is a basic setup to get you started. Depending on your requirements and environment, you might need to adjust configurations, add security, and handle high availability for the ELK stack.</p>
]]></content:encoded></item><item><title><![CDATA[Docker Password Authentication]]></title><description><![CDATA[The below Docker file creates an image with the customization you described, such as enforcing password authentication for the ls command and setting up a custom sudoers file. However, it's important to note that modifying system commands ls and usin...]]></description><link>https://project.neupanekrishna.com.np/docker-password-authentication</link><guid isPermaLink="true">https://project.neupanekrishna.com.np/docker-password-authentication</guid><category><![CDATA[Docker]]></category><category><![CDATA[docker images]]></category><category><![CDATA[Dockerfile]]></category><dc:creator><![CDATA[Krishna Neupane]]></dc:creator><pubDate>Thu, 28 Dec 2023 14:20:57 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1703773495319/bfc890cd-4db2-400a-a18d-efd66cd1025e.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>The below Docker file creates an image with the customization you described, such as enforcing password authentication for the <code>ls</code> command and setting up a custom sudoers file. However, it's important to note that modifying system commands <code>ls</code> and using unconventional security practices might have unintended consequences and potentially introduce security vulnerabilities.</p>
<pre><code class="lang-plaintext"># Use the official Ubuntu base image
FROM ubuntu:latest

# Set environment variables for the new user and password
ENV USER_NAME=myuser
ENV USER_PASS=mypassword

# Create a new user and set the password
RUN useradd -m $USER_NAME &amp;&amp; \
    echo "$USER_NAME:$USER_PASS" | chpasswd

# Install sudo and create a custom sudoers file to require password authentication
RUN apt-get update &amp;&amp; \
    apt-get install -y sudo &amp;&amp; \
    rm -rf /var/lib/apt/lists/* &amp;&amp; \
    echo "$USER_NAME ALL=(ALL:ALL) ALL, !/bin/bash" &gt; /etc/sudoers.d/custom_sudoers &amp;&amp; \
    chmod 0440 /etc/sudoers.d/custom_sudoers

# Create a custom shell script to enforce password authentication for ls
RUN echo '#!/bin/bash\nsudo /bin/ls "$@"' &gt; /usr/local/bin/ls &amp;&amp; \
    chmod +x /usr/local/bin/ls

# Add /usr/local/bin to the beginning of PATH
ENV PATH="/usr/local/bin:${PATH}"

# Set the default user to the newly created user
USER $USER_NAME

# Set the working directory to the user's home directory
WORKDIR /home/$USER_NAME

# Start a shell when running the container
CMD ["/bin/bash"]
</code></pre>
<p>The provided Docker file describes the steps to create a custom Docker image based on the official Ubuntu image. It creates a new user, sets a password, installs sudo, and customizes sudoers and the ls command. Let’s break down the Docker file step by step:</p>
<ol>
<li><p><code>FROM ubuntu:latest</code>This sets the base image to the latest version of Ubuntu.</p>
</li>
<li><p>Setting environment variables for the new user and password:</p>
</li>
</ol>
<pre><code class="lang-plaintext">ENV USER_NAME=myuser
ENV USER_PASS=mypassword
</code></pre>
<p>3. Creating a new user and setting the password:</p>
<pre><code class="lang-plaintext">RUN useradd -m $USER_NAME &amp;&amp; \
    echo "$USER_NAME:$USER_PASS" | chpasswd
</code></pre>
<p>4. Installing sudo and creating a custom sudoers file:</p>
<pre><code class="lang-plaintext">RUN apt-get update &amp;&amp; \
    apt-get install -y sudo &amp;&amp; \
    rm -rf /var/lib/apt/lists/* &amp;&amp; \
    echo "$USER_NAME ALL=(ALL:ALL) ALL, !/bin/bash" &gt; /etc/sudoers.d/custom_sudoers &amp;&amp; \
    chmod 0440 /etc/sudoers.d/custom_sudoers
</code></pre>
<p>5. Creating a custom shell script to enforce password authentication for the ls command:</p>
<pre><code class="lang-plaintext">RUN echo '#!/bin/bash\nsudo /bin/ls "$@"' &gt; /usr/local/bin/ls &amp;&amp; \
    chmod +x /usr/local/bin/ls
</code></pre>
<p>6. Adding <code>/usr/local/bin</code> to the beginning of the PATH:</p>
<pre><code class="lang-plaintext">ENV PATH="/usr/local/bin:${PATH}"
</code></pre>
<p>7. Setting the default user to the newly created user:</p>
<pre><code class="lang-plaintext">USER $USER_NAME
</code></pre>
<p>8. Setting the working directory to the user’s home directory:</p>
<pre><code class="lang-plaintext">WORKDIR /home/$USER_NAME
</code></pre>
<p>9. Starting a shell when running the container:</p>
<pre><code class="lang-plaintext">CMD ["/bin/bash"]
</code></pre>
<p>This Docker file creates an image with the customization you described, such as enforcing password authentication for the <code>ls</code> command and setting up a custom sudoers file. However, it's important to note that modifying system commands <code>ls</code> and using unconventional security practices might have unintended consequences and potentially introduce security vulnerabilities.</p>
]]></content:encoded></item></channel></rss>