Skip to content

Blog

Bad Owner Permissions Ssh Config Win

Fix Bad Owner / Permissions for SSH Config in Windows 10

Error:

  • Bad Owner or Permissions on SSH Config

Resolution:

  • Folder should only be accessible to SYSTEM and your logged in user

Steps:

  • Navigate to %USERPROFILE% in Windows Explorer
  • Right-Click on .ssh folder and choose Properties
  • Click on Security tab. It should only show your account and SYSTEM under "Group or user names". If not, here are the steps to take:
  • Click Advanced button
  • Click Disable inheritance button and Convert inherited permissions into explicit ...
  • Select and Remove any Principal in the list EXCEPT FOR your account name and SYSTEM
  • Click OK and then OK on the Properties window
  • You might perform similar steps on the all of the files in %UserProfile%\.ssh folder
  • If you run OpenSSH SSH Server, you might need to restart it in the services.msc

RPi (Raspberry Pi) Headless Dynamic IP Change Notification

Raspberry Pi Headless Server from Scratch

WHY

Since ISP (Internet Service Provider) started to change public IPs at will, I wanted to have sort of a control center network appliance that would monitor things like Public IP changes and possibly other things (like speed tests, checking if certain external sites are up, etc.) utilizing existing, unused, and, probably soon, outdated hardware.

WHAT

  • Raspberry Pi 1 Model B+ Board
  • Clear acrylic case for RPi Model B+
  • 8GB SD card
  • Old iPhone 1A adapter (works fine for Model 1b)
  • Micro USB to USB Cable
  • RJ45 Ethernet cable

HOW

Prepare RPi SD Card
  • Download Raspberry Pi OS Lite (at the time of writing Kernel version 5.00 released on March 4th 2021)
  • Download Balena Etcher or similar software to copy image to SD card (Raspberry Pi Imager did not work for me but was my first choice)
  • Plug SD Card into your Windows / OSX / Linux host machine and copy downloaded image to SD Card
  • Navigate to the SD Card (you might have more than one drive mounted / available under windows) and create an empty file named ssh (this will ensure that SSH server on headless Raspberry Pi (RPi) will start on the first boot)
First Time Setup
  • On windows I have download and installed wonderful Cygwin that provides a large collection of GNU and Open Source tools to provide functionality similar to a Linux distribution on windows. If using Windows 10, you might want to look into much heavier but "out of box" option called WSL2.
  • Unmount SD Card and plug it into RPi (via SD adapter if required), plug in RJ45 for wired internet connection (other side should go to your router), and then plug in Power cable.
  • RPi lights will be lit.
  • Identify an IP address of newly built RPi using either your Router's DHCP list of IPs -- RPi MAC addresses would start with B8-27-EB or use one of the utilities like Adafruit Pi Finder, nmap, Angry IP Scanner (try older version with a single executable ipscan.exe), or just type in something like "ping -4 raspberrypi.local" at the command prompt.
Sample Naming
  • RPi hostname: raspberry ==> headless_horseman
  • RPi IP Address: 192.168.1.123
  • SSH Port: 22 ==> 7522
  • Sample Sudo User / Pass: mysudouser / Pwd.926!
  • Sample SSH User / Pass: mysshuser / T3n.F0ur!
  • SSH Public key file on Host machine: ~/.ssh/id_rsa-headless_horseman.pub
First Time Login
  • Using Cygwin or WSL2 (from windows) or Terminal (on OSX / Linux), connect to RPi (default user "pi" with default password "raspberry"): user@host $ ssh pi@192.168.1.123

  • To enable SSH for the future boots one can use "sudo raspi-config" or via command line: pi@192.168.1.123 $ sudo systemctl enable ssh # enable ssh

  • Change default "pi" password (optionally - user "pi" can be removed in the future if another user is created): pi@192.168.1.123 $ passwd

  • Change default hostname: pi@192.168.1.123 $ sudo vi /etc/hostname

  • To add users:

pi@192.168.1.123 $ sudo adduser mysshuser #add user for non-sudo SSH access

pi@192.168.1.123 $ sudo adduser mysudouser sudo #add user for sudo non-SSH access

pi@192.168.1.123 $ sudo usermod -aG sudo mysudouser #OPTIONAL: add user to sudo group (covered by adduser with 'sudo' group name at the end)

Remove ability for ssh user to browse sudo user folder:

pi@192.168.1.123 $ sudo chmod 0750 /home/mysudouser

  • Modify SSH Config to Allow / deny certain users and change default port (append at the end):

pi@192.168.1.123 $ sudo vi /etc/ssh/sshd_config

Port 7522 # Change Port to 7522 from default 22
AllowUsers mysshuser # allow SSH
DenyUsers mysudouser # sudo user to be denied SSH
PermitRootLogin=no # do not allow root login via ssh
 SSH Server needs to be restarted for changes to take effect. Status can be queried as well:

pi@192.168.1.123 $ sudo systemctl restart ssh

pi@192.168.1.123 $ sudo systemctl status ssh

Setup Host machine for Passwordless SSH login
  • In terminal in the host machine (cygwin, wsl2, terminal, etc.) key needs to be available or generated (accept default empty value for passphrase by pressing ENTER):

user@host $ mkdir -p ~/.ssh && cd ~/.ssh

user@host $ ssh-keygen -f id_rsa-headless_horseman

  • Copy public key to RPi (target is ~/.ssh/authorized_keys):

user@host $ ssh-copy-id -i ~/.ssh/id_rsa-headless_horseman -p 7522 mysshuser@192.168.1.123

  • Create configuration file for SSH to avoid supplying parameters every time:

user@host $ vi ~/.ssh/config

Host headless_horseman
  HostName 192.168.1.123
  User mysshuser
  Port 7522
  IdentityFile ~/.ssh/id_rsa-headless_horseman
Connect to RPi:

user@host $ ssh headless_horseman

mysshuser@headless_horseman $ su - mysudouser

Delete pi user

mysudouser@headless_horseman $ sudo userdel -r pi

Create scripts folder:

mysudouser@headless_horseman $ mkdir -p ~/scripts

Install fail2ban

mysudouser@headless_horseman $ sudo apt-get update

mysudouser@headless_horseman $ sudo apt-get -y

install fail2ban

mysudouser@headless_horseman $ sudo vi /etc/fail2ban/jail.local

[ssh]
enabled = true
port = 7522
filter = sshd
logpath = /var/log/auth.log
bantime = 900
banaction = iptables-allports
findtime = 900
maxretry = 3

mysudouser@headless_horseman $ sudo systemctl restart fail2ban

mysudouser@headless_horseman $ sudo iptables -L -n --line #check banned addresses

mysudouser@headless_horseman $ sudo iptables -D fail2ban-ssh 1 #unban line number 1

mysudouser@headless_horseman $ ln -s -T /var/log/fail2ban.log ~/scripts/fail2ban.log

Modify prompt and ls alias

mysudouser@headless_horseman $ vi ~/.profile

export PS1="\[\033[0;33m\][\D{%Y-%m-%d}][\t]\[\033[0;36m\] [\u\[\033[0;37m\]@\[\033[0;36m\]\h:\[\033[0;32m\]\w]\[\033[0m\] \n$ "
alias ls='ls -laFh --color=auto'

Script: update.sh

mysudouser@headless_horseman $ vi ~/scripts/update.sh

#!/bin/bash
sudo apt update;
sudo apt -y upgrade;
sudo apt -y autoclean;
sudo apt -y autoremove;
sudo shutdown -r

mysudouser@headless_horseman $ chmod +x ~/scripts/update.sh

mysudouser@headless_horseman $ sudo crontab -e

30 23  *  * WED /bin/bash /home/mysudouser/scripts/update.sh
Script: myutil.py

mysudouser@headless_horseman $ vi ~/scripts/myutil.py && chmod +x ~/scripts/myutil.py

#!/usr/bin/env python3

def getip(networkCardName):
    import subprocess
    return subprocess.getoutput("ip addr show " + networkCardName + " | grep -Po 'inet \K[\d.]+'")

def getips():
    import re
    import subprocess
    # get ip(s) from ifconfig
    found_ips = []
    ips = re.findall( r'[0-9]+(?:\.[0-9]+){3}', subprocess.getoutput("/sbin/ifconfig"))
    for ip in ips:
        if ip.startswith("255") or ip.startswith("127") or ip.endswith("255"):
            continue
        found_ips.append(ip)
    return ", ".join(found_ips)

def emailsend(subjectPart, messagePart):
    import time
    import smtplib
    import socket

    from datetime import datetime
    current_utc = datetime.utcnow().isoformat() + 'Z'

    ####--[CONFIGURATION]
    server = 'smtp.gmail.com'
    server_port = '587'
    username = 'MYEMAIL@gmail.com'
    password = 'MYGMAILPA$$'

    fromaddr = 'DEVOPS <MYEMAIL@gmail.com>'
    toaddr = 'TARGET_EMAIL@domain.com'
    subject = 'DEVOPS | ' + socket.gethostname() + ' | ' + subjectPart
    message = 'DEVOPS | ' + socket.gethostname() + ' | <br>' + messagePart + '<br><br><br>Email Generated On: ' + current_utc
    ####--[/CONFIGURATION]
    headers = [
        "Subject: " + subject,
        "From: " + fromaddr,
        "To: " + toaddr,
        "MIME-Version: 1.0",
        "Content-Type: text/html"
        ]
    headers = "\r\n".join(headers)
    server = smtplib.SMTP(server + ":" + server_port)
    server.ehlo()
    server.starttls()
    server.ehlo()
    server.login(username,password)
    server.sendmail(fromaddr, toaddr, headers + "\r\n\r\n" + message)
    server.quit()

def get_script_path():
    import os
    import sys
    return os.path.dirname(os.path.realpath(sys.argv[0]))
Script: ipcheck.py

mysudouser@headless_horseman $ vi ~/scripts/ipcheck.py && chmod +x ~/scripts/ipcheck.py

#!/usr/bin/env python3

import json, os
import urllib.request
import myutil
from datetime import date

today = date.today()

formatted_date = today.strftime("%Y%m%d")

script_dir = myutil.get_script_path()

ipcheck_url = "https://mydomain.com/ipcheck.php"
ipcheck_log = script_dir + "/ipcheck_changes-py.log"
lastip_filename = script_dir + "/ipcheck_lastip-py.txt"
lastip = "unknown"

if os.path.isfile(lastip_filename):
    with open(lastip_filename, 'r') as f:
        lastip = f.read()

data = json.loads(urllib.request.urlopen(ipcheck_url).read())
currentip = data["ip"]

if lastip != currentip:
    with open(lastip_filename, 'w') as f:
        f.write(currentip)
    with open(ipcheck_log, 'a') as f:
        f.write(formatted_date + " " + currentip + '\n')
    subject = "Public IP address change"
    message = "Old IP: " + lastip + " / New IP: " + currentip
    myutil.emailsend(subject, message)
Create a script on external web site (mydomain.com) named ipcheck.php as follows
<?php
header('Content-Type: application/json');
$ip=$_SERVER["REMOTE_ADDR"];
$arr=array( "ip" => $ip );
echo json_encode($arr);
?>

mysudouser@headless_horseman $ sudo crontab -e

*/1  *  *  *   * /usr/bin/python3 /home/mysudouser/scripts/ipcheck.py
Script: i_am_alive_email.py

mysudouser@headless_horseman $ vi ~/scripts/i_am_alive_email.py && chmod +x ~/scripts/i_am_alive_email.py

#!/usr/bin/env python3
import time
import myutil
# wait for interface to initialize before parsing ifconfig
time.sleep(1)
subject = "IP address(es)"
# ifconfig will show networkCardName
networkCardName = "eth0"
message = myutil.getip(networkCardName)
myutil.emailsend(subject, message)

mysudouser@headless_horseman $ sudo crontab -e

33 03  *  *   * /usr/bin/python3 /home/mysudouser/scripts/i_am_alive_email.py

Bash Prompt and ls Alias

Prompt: [2020-03-13][23:49:21] [pi@raspberry:~]

  • Add at the end of ~/.profile
##### modify standard command prompt
# \n = new line; \u = current username; \w = current working dir (home = ~)
##### Colors
# Black       0;30     Dark Gray     1;30
# Blue        0;34     Light Blue    1;34
# Green       0;32     Light Green   1;32
# Cyan        0;36     Light Cyan    1;36
# Red         0;31     Light Red     1;31
# Purple      0;35     Light Purple  1;35
# Brown       0;33     Yellow        1;33
# Light Gray  0;37     White         1;37

export PS1="\[\033[0;33m\][\D{%Y-%m-%d}][\t]\[\033[0;36m\] [\u\[\033[0;37m\]@\[\033[0;36m\]\h:\[\033[0;32m\]\w]\[\033[0m\] \n$ "

##### Modify default ls command
# -G colorizes output
# -h makes sizes human readable
# -F throws a / after a directory, * after an executable, and a @ after a symlink
# -l listing format (as opposed to default wide)
# -a shows all files (even hidden)
alias ls='ls -laGFh'

Python Script to Get Local IPs

Python 3 Script to Get IPs

#!/usr/bin/env python3

def getips():
    import re
    import subprocess

    # get ip(s) from ifconfig
    found_ips = []
    ips = re.findall( r'[0-9]+(?:\.[0-9]+){3}', subprocess.getoutput("/sbin/ifconfig"))
    for ip in ips:
        if ip.startswith("255") or ip.startswith("127") or ip.endswith("255"):
            continue
        found_ips.append(ip)

    return ", ".join(found_ips)

Check Speed of Dns Servers wtih Dig

Check the speed of OpenDNS and Google Public DNS servers

OpenDNS Server addresses:

  • 208.67.222.222
  • 208.67.220.220

Google Public DNS Server addresses:

  • 8.8.8.8
  • 8.8.4.4

Test Server: brooklyn-chess.com

echo OpenDNS ... ; 
dig @208.67.222.222 brooklyn-chess.com | grep Query;
dig @208.67.220.220 brooklyn-chess.com | grep Query;

echo Google DNS ... ; 
dig @8.8.8.8 brooklyn-chess.com | grep Query;
dig @8.8.4.4 brooklyn-chess.com | grep Query;

Python 3 Script to Send Mail via Gmail

Python 3 Script to Send eMail via GMail

def emailsend(subject_part, message_part):
    # usage: emailsend("Server is up", "")
    import time
    import smtplib
    import socket

    from datetime import datetime
    current_utc = datetime.utcnow().isoformat() + 'Z'

    ####--[CONFIGURATION]
    server = 'smtp.gmail.com'
    server_port = '587'
    username = 'INSERT-YOUR-USERNAME@gmail.com'
    password = 'INSERT-YOUR-PASSWORD'
    hostname = socket.gethostname()

    from_addr = 'INSERT-YOUR-FROM-NAME <INSERT-YOUR-FROM@gmail.com>'
    to_addr = 'INSERT-YOUR-TO-EMAIL'
    subject = 'INSERT-YOUR-SUBJECT-PREPEND | ' + hostname + ' | ' + subject_part
    message = 'INSERT-YOUR-MESSAGE-PREPEND | ' + hostname + ' | <br>' + message_part + '<br><br><br>Email Generated On (UTC): ' + current_utc
    ####--[/CONFIGURATION]

    headers = [
            "Subject: " + subject,
            "From: " + from_addr,
            "To: " + to_addr,
            "MIME-Version: 1.0",
            "Content-Type: text/html"
            ]
    headers = "\r\n".join(headers)

    server = smtplib.SMTP(server + ":" + server_port)
    server.ehlo()
    server.starttls()
    server.ehlo()
    server.login(username,password)
    server.sendmail(from_addr, to_addr, headers + "\r\n\r\n" + message)
    server.quit()

Start Dev IIS Express Server

Start Development IIS Express Server (tested on Win7 and Win10 with mapped network drives)

@echo off
REM Script will start IIS Express on the specific port with the folder FROM WHICH SCRIPT IS CALLED
REM 
REM IIS Express does the following:
REM * Copies default applicationhost.config file ("C:\Program Files\IIS Express\AppServer\applicationhost.config") to %TEMP%\IISEXPRESS\APPLICATIONHOST{TimeStampGoesHere}.CONFIG (where timestamp is current date+time with milliseconds)
REM * The copied config file is modified to specify the physical path (<application ...> --> <virtualDirectory ...> physicalPath property) and the port (<bindings> -> <binding ...> bindingInformation property) 
REM * Path to custom configuration file can also be provided in the command line using /config:{FullPathToIISApplicationHostCustomConfigFile}

set iisexpress_loc="C:\Program Files\IIS Express\iisexpress.exe"
set folder_loc=%cd%
set port_loc=2018

if [%1]==[--help] goto syntax
if [%1]==[/?] goto syntax

if [%1]==[] goto proceed
set port_loc=%1

:proceed
echo.
echo Make "%folder_loc%" accessible from "http://localhost:%port_loc%" ...
echo.

%iisexpress_loc% /path:"%folder_loc%" /port:%port_loc% /trace:w /systray:true

goto exit

:syntax
echo.
echo Syntax: %0 PortNumberGoesHere
echo         Default Port: %port_loc%
echo.
goto exit

:exit
echo.
echo.
echo.
pause

Bash Profile Settings 1

Bash has five prompt strings that can be customized:

  • PS0 -> displayed after each command before any output;
  • PS1 -> primary prompt which is displayed before each command;
  • PS2 -> secondary prompt displayed when a command needs more input (e.g. a multi-line command).
  • PS3 -> not very commonly used. It is the prompt displayed for Bash's select built-in which displays interactive menus. Unlike the other prompts, it does not expand Bash escape sequences. Usually you would customize it in the script where the select is used rather than in your .bashrc.
  • PS4 -> is also not commonly used. It is displayed when debugging bash scripts to indicate levels of indirection. The first character is repeated to indicate deeper levels.

PS1 Color Prompt for Bash

[2017-04-14][20:52:25] [username@hostname]:~
$
  • Modify .bash_profile, .profile, or .bashrc (if using bash)
.bash_profile
export PS1="\[\033[0;33m\][$(date +%Y-%m-%d)][\t]\[\033[0;36m\] [\u\[\033[0;37m\]@\[\033[0;36m\]\h]:\[\033[0;32m\]\w\[\033[0m\] \n$"

alias ls='ls -laGFh'
Colors and Prompt Variables
##### modify standard command prompt
# \n   = new line; 
# \u   = username; 
# \h   = hostname;
# \t   = time;
# \w   = current working dir (home = ~);
# \A   = current time;
# \$?  = exit code/status from previous command;
# \033 = starts all escape sequences (^[ or \x1B)


##### Colors
# Black       0;30     Dark Gray     1;30
# Blue        0;34     Light Blue    1;34
# Green       0;32     Light Green   1;32
# Cyan        0;36     Light Cyan    1;36
# Red         0;31     Light Red     1;31
# Purple      0;35     Light Purple  1;35
# Brown       0;33     Yellow        1;33
# Light Gray  0;37     White         1;37
Linux ls command modifications
##### Modify default ls command
# -G colorizes output
# -h makes sizes human readable
# -F throws a / after a directory, * after an executable, and a @ after a symlink
# -l listing format (as opposed to default wide)
# -a shows all files (even hidden)

More Info

Richtextbox Output Log4net Appender

Use RichTextBox as an output of Log4net Appender

Step 1


  • Create a Windows Forms Application project named "Sample" using Visual Studio (the code is in c#).

Step 2


  • Get log4net library by either downloading it from https://logging.apache.org/log4net/ or by installing the package through NuGet Package Manager.

Step 3


  • Create folder "lib" under the project and place files there.
  • Add reference to lib\log4net.dll

Step 4


  • Please rename default form to "FrmSample". On the default form add a button and a RichTextBox.
  • Please name the RichTextBox as "RtbOutput" and a button as "CmdGenerateTestLogs".

Step 5


  • In the root of the project folder create XML file: log4net.config
  • In Properties for the file set: Copy to Output Directory: Copy if newer
  • Populate file with following (log file appender will create a file in logs folder with the file name of output.log; once file size reaches 10MB, new file will be created. Maximum of 10 log files will be retained). Please change "Sample" with the name of your project namespace, form name "FrmSample" with the name of the windows form name, text box name "RtbOutput" with the name of the RichTextBox that would be used to output log4net messages:
<?xml version="1.0" encoding="utf-8" ?>
<log4net xmlns="urn:log4net">
  <appender name="LogFileAppender" type="log4net.Appender.RollingFileAppender">
    <param name="file" value="logs\output.log" />
    <param name="appendToFile" value="true" />
    <param name="rollingStyle" value="Size" />
    <param name="maxSizeRollBackups" value="10" />
    <param name="maximumFileSize" value="10MB" />
    <param name="staticLogFileName" value="true" />
    <layout type="log4net.Layout.PatternLayout">
      <param name="conversionPattern" value="%date [%thread] %-5level %logger - %message%newline" />
    </layout>
  </appender>
  <appender name="ConsoleAppender" type="log4net.Appender.ConsoleAppender">
    <layout type="log4net.Layout.PatternLayout">
      <conversionPattern value="%date [%thread] %-5level %logger - %message%newline" />
    </layout>
  </appender>
  <appender name="RichTextBoxAppender" type="Sample.RichTextBoxAppender, Sample">
    <formName value="FrmSample"/>
    <textBoxName value="RtbOutput"/>
    <layout type="log4net.Layout.PatternLayout">
      <conversionPattern value="%date %-5level - %message%newline" />
    </layout>
  </appender>
  <root>
    <level value="DEBUG" />
    <appender-ref ref="LogFileAppender" />
    <appender-ref ref="ConsoleAppender" />
    <appender-ref ref="RichTextBoxAppender" />
  </root>
</log4net>

Step 6


  • To enable logging, under the Properties folder double-click on AssemblyInfo.cs and add the following line at the end of the file:
[assembly: log4net.Config.XmlConfigurator(ConfigFile = "log4net.config", Watch = true)]

Step 7


  • Add a new class RichTextBoxAppender.cs to the project. Paste the following into the class file replacing existing text:
using System.Drawing;
using System.Windows.Forms;
using log4net.Appender;
using log4net.Core;

namespace Sample
{
    public class RichTextBoxAppender : AppenderSkeleton
    {
        private RichTextBox _textBox;
        public RichTextBox AppenderTextBox { get { return _textBox; } set { _textBox = value; } }
        public string FormName { get; set; }
        public string TextBoxName { get; set; }

        private static Control FindControlRecursive(Control root, string textBoxName)
        {
            if (root.Name == textBoxName) return root;
            foreach (Control c in root.Controls)
            {
                var t = FindControlRecursive(c, textBoxName);
                if (t != null) return t;
            }
            return null;
        }

        protected override void Append(LoggingEvent loggingEvent)
        {
            if (_textBox == null)
            {
                if (string.IsNullOrEmpty(FormName) || string.IsNullOrEmpty(TextBoxName)) return;

                var form = Application.OpenForms[FormName];
                if (form == null) return;

                _textBox = (RichTextBox)FindControlRecursive(form, TextBoxName);
                if (_textBox == null) return;

                form.FormClosing += (s, e) => _textBox = null;
            }
            _textBox.BeginInvoke((MethodInvoker)delegate
            {
                if (loggingEvent.Level == Level.Debug)
                {
                    _textBox.SelectionStart = _textBox.TextLength;
                    _textBox.SelectionLength = 0;
                    _textBox.SelectionColor = Color.RoyalBlue;
                    _textBox.AppendText(RenderLoggingEvent(loggingEvent));
                    _textBox.SelectionColor = _textBox.ForeColor;
                }
                else if (loggingEvent.Level == Level.Info)
                {
                    _textBox.SelectionStart = _textBox.TextLength;
                    _textBox.SelectionLength = 0;
                    _textBox.SelectionColor = Color.ForestGreen;
                    _textBox.AppendText(RenderLoggingEvent(loggingEvent));
                    _textBox.SelectionColor = _textBox.ForeColor;
                }
                else if (loggingEvent.Level == Level.Warn)
                {
                    _textBox.SelectionStart = _textBox.TextLength;
                    _textBox.SelectionLength = 0;
                    _textBox.SelectionColor = Color.DarkOrange;
                    _textBox.AppendText(RenderLoggingEvent(loggingEvent));
                    _textBox.SelectionColor = _textBox.ForeColor;
                }
                else if (loggingEvent.Level == Level.Error)
                {
                    _textBox.SelectionStart = _textBox.TextLength;
                    _textBox.SelectionLength = 0;
                    _textBox.SelectionColor = Color.DarkRed;
                    _textBox.AppendText(RenderLoggingEvent(loggingEvent));
                    _textBox.SelectionColor = _textBox.ForeColor;
                }
                else if (loggingEvent.Level == Level.Fatal)
                {
                    _textBox.SelectionStart = _textBox.TextLength;
                    _textBox.SelectionLength = 0;
                    _textBox.SelectionColor = Color.Crimson;
                    _textBox.AppendText(RenderLoggingEvent(loggingEvent));
                    _textBox.SelectionColor = _textBox.ForeColor;
                }
                else
                {
                    _textBox.AppendText(RenderLoggingEvent(loggingEvent));
                }
            });
        }
    }
}

Step 8


  • Open the code behind the form by pressing F7 on the form and paste following code:
using System;
using System.Drawing;
using System.Windows.Forms;
using log4net;

namespace Sample
{
    public partial class FrmSample : Form
    {

        private static readonly ILog Log = LogManager.GetLogger(typeof(FrmSample));

        public FrmSample()
        {
            InitializeComponent();

            #region Set properties for RtbOutput as per your choice
            RtbOutput.BackColor = System.Drawing.SystemColors.Control;
            RtbOutput.HideSelection = false;
            RtbOutput.ReadOnly = true;
            RtbOutput.Text = "";
            RtbOutput.WordWrap = false;
            RtbOutput.Font = new Font(FontFamily.GenericMonospace, 9);
            #endregion
        }

        private void CmdGenerateTestLogs_Click(object sender, EventArgs e)
        {
            Log.Debug("This is a DEBUG message");
            Log.Info("This is a INFO message");
            Log.Warn("This is a WARN message");
            Log.Error("This is a ERROR message");
            Log.Fatal("This is a FATAL message");
        }
    }
}

Step 9


  • Running program and clicking on the button should print out the log (same log will appear in the output.log file under log folder - check the project output directory). Feel free to modify the properties of the RichTextBox as you fit.

Open Ports Verizon Router Fios G1100

Forward port on Verizon FiOS Router G1100

Information Required:

  • Local IP Address of FiOS Router (by default 192.168.1.1) : {IP_ADDRESS_OF_FIOS_ROUTER}
  • Username and Password to login to the FiOS Router (usually on the sticker on your router).
  • Local IP Address of the Device that should be servicing Forwarded Port.
  • Port to be forwarded.

Steps:

  • Open browser and type in the http://IP_ADDRESS_OF_FIOS_ROUTER.
  • Type in "User Name" and "Password" of your router.
  • Choose "Firewall" from the top menu.
  • Click "Yes" button on the "Warning / Any changes made in this section may affect your router's performance and configuration. / Do you want to proceed?" screen.
  • Click "Port Forwarding" link on the left menu.
  • Under "Create new port forwarding rule" in the first drop down box "Select IP from menu" to select an IP address of the device on your network that should be accepting the request from the remote computer.
  • Click on "Application To Forward..." dropdown and choose "Custom Ports".
  • Choose the protocol: TCP, UDP, or Both and overwrite port 65535 with the port number of your choice.
  • Click "Add".
  • Do NOT CLICK "Advanced>>" and choose port that way.
  • Click "Logout" link on the left menu.
  • The "Port Forwarding" is completed.