Category: Linux Server

  • Ntfy: push notification for services.

    I am using Ntfy for my SSH alert and watchtower update. It is pretty cool to have this feature, so I can know who is accessing my server without my authorization. And know my docker needs to be updated as well.

    SSH Alert Example

    Command this to open code,

    nano /etc/pam.d/sshd

    Please add this code to the bottom of the page.

    session optional pam_exec.so /usr/local/bin/ntfy-ssh-login.sh

    You should create a script file called /usr/local/bin/ntfy-ssh-login.sh

    nano /usr/local/bin/ntfy-ssh-login.sh

    Here code, make sure you change the server URL and username and password for nginx auth.

    #!/bin/bash
    # This is a PAM script hook that shows how to notify you when
    # somebody logs into your server. Place at /usr/local/bin/ntfy-ssh-login.sh (with chmod +x!).
    
    TOPIC_URL=yourntfydomain
    NGINXUSER=yourusername
    NGINXPASSWORD=yourpassword
    
    if [ "${PAM_TYPE}" = "open_session" ]; then
      curl -u ${NGINXUSER}:${NGINXPASSWORD} -H tags:warning -H prio:high -d "SSH login to $(hostname): ${PAM_USER} from ${PAM_RHOST}" "${TOPIC_URL}"
    fi

    Then Now you save Ctrl +x then yes

    Make sure you have chmod permissions. Here is the command.

    chmod +x /usr/local/bin/ntfy-ssh-login.sh

    Go try logging into another terminal and see if it notifications you, then try logging in again and see if it notifications you. 🙂

    It works well. It shows the username and IP address, so the IT team can protect the account if they don’t have permission to access our server.

  • How to Set Up and Log In to Bitwarden Password Manager on a Self-Hosted Server

    Step by step:

    1. Download the Android apps “Bitwarden Password Manager” and for apple “Bitwarden Password Manager
    2. Open Bitwarden password app
    3. Login in on → self-hosted
    4. Server URL is Https://bitwarden.richardapplegate.io
    5. Login to your account. If you don’t have one, ask Richard Applegate to open a registration. I have to close the register to be more secure and stay away from bots.
  • How to build a Dockerfile on Windows 10?

    Building a Dockerfile on Windows 11 is a common workflow for containerized development. Here’s how you can do it—step by step:


    1. Install Docker Desktop for Windows

    • Go to the Docker Desktop download page.
    • Download the Windows installer and run it.
    • Follow the prompts (ensure “WSL2” support is selected, if available).
    • NOTE: Windows 11 works best with WSL2.

    2. Write Your Dockerfile

    • Use a code editor (e.g., VS Code, Notepad++).
    • Save your Dockerfile as simply named: Dockerfile (no extension).
    • Example (Python app):
    FROM python:3.11-slim
    WORKDIR /app
    COPY . .
    RUN pip install -r requirements.txt
    CMD ["python", "app.py"]

    3. Open a Terminal

    • On Windows, you can use:
    • Windows Terminal (wt command)
    • Command Prompt (cmd)
    • PowerShell
    • WSL2 Terminal (Recommended)

    4. Navigate to the Dockerfile Location

    Use the cd command to go to your project directory:

    cd path\to\your\project

    5. Build the Docker Image

    Use the docker build command. For example:

    docker build -t my-app:latest .
    • -t my-app:latest gives your image a name and tag (latest).
    • The final . means “use the Dockerfile in the current directory”.

    6. Run the Docker Container (Optional)

    Test your image:

    docker run --rm -it my-app:latest

    7. Troubleshooting

    • If Docker commands aren’t recognized, make sure Docker Desktop is running.
    • Check Windows Terminal settings if using WSL2, and ensure file sharing is set up for your code folders.

    Summary Table

    StepCommand/Action
    Install DockerDownload & install Docker Desktop
    Write DockerfileUse text editor, save as Dockerfile
    Open TerminalPowerShell, CMD, WSL or Windows Terminal
    Go to directorycd path\to\project
    Build imagedocker build -t my-app:latest .
    Run containerdocker run --rm -it my-app:latest

    Tip: You can use Docker Desktop’s GUI to see your images and containers as well!

Secret Link