Recent Posts

Featured image for Customizing Tmux Behavior and SSH Banner Display

Customizing Tmux Behavior and SSH Banner Display

Tmux is a versatile terminal multiplexer that allows you to manage multiple terminal sessions within a single window. Additionally, you can customize Tmux behavior to suit your preferences and automate tasks. This article presents a collection of Bash scripts designed to customize Tmux behavior and display an SSH banner when starting Tmux. Let’s explore each script’s purpose and functionality.

Script 1: Show SSH Banner on Start Tmux

bash
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
if [[ -z "$TMUX" ]]; then
    tmux has-session &> /dev/null
    if [ $? -eq 1 ]; then
        shopt -q login_shell && exec tmux new
        exit
    else
        shopt -q login_shell && exec tmux attach
        exit
    fi
else
    TMUX_WINDOW=$(tmux display-message -p '#{session_windows}')
    if [ $TMUX_WINDOW == "1" ]; then
        shopt -q login_shell && run-parts /etc/update-motd.d/
    fi
fi

This script is designed to display an SSH banner when starting Tmux. It checks whether the TMUX environment variable is empty, which indicates that Tmux is not currently running. If Tmux is not running and the current shell is a login shell, it starts a new Tmux session. If Tmux is already running, it attaches to the existing session. If there’s only one window in the Tmux session, the script runs the /etc/update-motd.d/ script to show a message of the day for SSH sessions.

Featured image for UFW Not Starting on Boot in Ubuntu 18.04

UFW Not Starting on Boot in Ubuntu 18.04

If you’re experiencing issues with the Uncomplicated Firewall (UFW) not starting on boot in Ubuntu 18.04, there are a few steps you can take to troubleshoot and resolve the problem. Here’s a step-by-step guide to fix the issue.

Please note: Modifying system files requires administrative privileges. Make sure you have the necessary permissions before proceeding.

Editing the UFW Service File

  1. Open a terminal or SSH session and log in to your Ubuntu 18.04 system.
  2. Use the following command to open the UFW service file in the Vim text editor:
bash
1
sudo vim /lib/systemd/system/ufw.service
  1. Inside the Vim editor, locate the line that reads Before=network.target. You need to remove this line from the file. To do so, move the cursor to that line, press dd to delete the line, and then save the file and exit Vim by typing :wq.

  2. Next, you need to add the line After=network.target to the UFW service file. To do this, move the cursor to an empty line after the [Service] section, press o to start a new line, and then type After=network.target. Save the file and exit Vim by typing :wq.

Featured image for Filtering Windows Events by User Account

Filtering Windows Events by User Account

In Windows, you can filter events in the event logs based on specific criteria, such as the user account associated with an event. This can be particularly useful for security and auditing purposes. Below are examples of XML queries that filter Windows events by user account using XPath expressions.

Example 1: Filter Successful Logon Events (Event ID 4624) by User Account

This example demonstrates how to filter successful logon events (Event ID 4624) in the Security event log for a specific user account, in this case, “john.doe.”

Featured image for SSHD Windows 10 Not Accepting Public Key

SSHD Windows 10 Not Accepting Public Key

If you’re experiencing issues with SSHD on Windows 10 not accepting your public key, there are a few steps you can take to troubleshoot the problem. Follow the steps below to resolve the issue.

Step 1: Open the SSHD Configuration File

To begin, open the SSHD configuration file using a text editor. In this example, we’ll use the Bash shell and the vim editor. Open a command prompt and navigate to the following directory:

Featured image for Sharing Docker Daemon from Windows to Local Network

Sharing Docker Daemon from Windows to Local Network

To share the Docker Daemon running on a Windows machine with other devices on your local network, you can use the netsh command to perform port forwarding. This will allow you to access the Docker Daemon remotely using the machine’s IP address and the forwarded port. Here’s how you can do it:

  1. Open Command Prompt as Administrator: To execute the netsh command, you need administrative privileges. Right-click on the Command Prompt and choose “Run as administrator.”

  2. Enable Docker Daemon Port: By default, the Docker Daemon listens on localhost (127.0.0.1) for security reasons. To enable it to listen on all interfaces, including your local network, you’ll need to modify the Docker Daemon configuration. Locate the daemon.json file located at C:\ProgramData\Docker\config\daemon.json and add the following configuration:

    json
    1
    2
    3
    
    {
      "hosts": ["tcp://0.0.0.0:2375", "npipe://"]
    }

    Save the file and restart the Docker service for the changes to take effect.

  3. Add Port Proxy Rule: Use the netsh command to set up port forwarding from a specific IP address and port to the Docker Daemon’s IP address and port. In this example, we’ll forward port 2375 from the machine’s IP address 192.168.100.7 to localhost:2375 where the Docker Daemon is running.

    sh
    1
    
    netsh interface portproxy add v4tov4 listenport=2375 connectaddress=127.0.0.1 connectport=2375 listenaddress=192.168.100.7 protocol=tcp

    This command forwards incoming traffic on port 2375 of the specified IP address (192.168.100.7) to the Docker Daemon running at 127.0.0.1:2375.

  4. Access Docker Daemon Remotely: Now, you should be able to access the Docker Daemon from other devices on your local network by using the IP address of the Windows machine (192.168.100.7 in this case) and port 2375. For example, you can use the following command to check if the Docker Daemon is reachable:

    sh
    1
    
    docker -H tcp://192.168.100.7:2375 info

    Replace 192.168.100.7 with the actual IP address of your Windows machine.

Featured image for Troubleshooting L2TP VPN Connection Issue on Windows 10

Troubleshooting L2TP VPN Connection Issue on Windows 10

If you’re experiencing difficulties connecting to an L2TP VPN (Layer 2 Tunneling Protocol) on Windows 10, there are a few troubleshooting steps you can follow. This guide will walk you through the process of adding a registry key and ensuring the necessary protocols are allowed to establish a successful L2TP VPN connection.

Adding the Registry Key

To begin, you’ll need to add a registry key that can help resolve L2TP VPN connectivity issues. Follow the steps below: