Posts


https://www.vultr.com

The Everywhere Cloud

Deploy an instance.
Accelerate your application.


Running Home Assistant on FreeBSD Servers

Image
Home Assistant is an open-source home automation system powered by Python, primarily intended to run on single-board computers like the Raspberry Pi, with Linux as the host operating system. The following procedure shows how to run Home Assistant Core on FreeBSD servers, on either physical or virtual machines. ========== 1. PREPARING THE SERVER 1.1. Update the package list and upgrade the existing packages. root@host: # pkg update && pkg upgrade -y 1.2. Install Python and other required packages. root@host: # pkg install python38 py38-sqlite3 openssl autoconf libffi rust 1.3. Create a system account with disabled login (-w no), a dedicated home directory (-m), and some informational text (-c comment). root@host: #  pw useradd homeassistant -w no -m -c "Home Assistant" 1.3.1. If groups for hardware input/output are present, append the system account. Else, skip this step for now. root@host: #  pw groupmod gpio -m homeassistant root@host: #  pw groupmod i2c -m ...

Running FreeBSD Commands at Startup

Image
The following procedure enables FreeBSD programs to start automatically after booting, without requiring users to log in first. This method is useful when automating custom daemons to act as servers with user-specific privileges. This is almost identical to the Linux procedure , except for one redirection parameter excluded here. ========== 1. Edit the user crontab file. user@host: $ crontab -e 2. Add the @reboot line with the desired command. # BEGIN CODE @reboot /myfolder/mydaemon.sh > /dev/null & # "> /dev/null" discards standard output by redirecting to the null device. # Terminating with "&" executes the command in the background. # END CODE 3. Save and exit crontab, then reboot the machine. ========== The default shell configured in an account's environment variables is used by crontab to process the listed commands. In Linux crontab , the default Bourne Again shell (bash) accepts parameters like "2>&1" which redirects standa...

Configuring the FreeBSD Firewall with IPFW

Image
IPFW is one of several firewalls included in FreeBSD by default. It has a command-line tool to handle the policies for incoming and outgoing connections. In the configurations discussed here, network connections "from any to any" are deliberately avoided to prevent potential bounce attacks from happening, if the server is not intended to act as a router. Instead, a request/respond or incoming/outgoing rule pair is adopted to direct the flow of network traffic. The main objective is to set up IPFW to block unauthorized remote access to unsecured ports on the server. But if attackers manage to break in through a vulnerability on some programs running on authorized incoming ports, the outgoing restrictions will prevent massive data exfiltration, stopping intruders dead in their tracks. A similar approach can be done on Debian-based Linux distributions using UFW . ========== 1. STRICT CONFIGURATION 1.1. Create a custom shell script for IPFW commands. root@host: #  ee /etc/...

Samba Print Client in Debian-based Linux

Image
The following procedure demonstrates how to enable Debian-based Linux distributions to access printers hosted on old Windows 7 machines via Samba protocols. This process has been tested on Epson L210 Series inkjet printers. ========== 1. Open the Samba configuration file. user@host: $ sudo nano -c /etc/samba/smb.conf 2. Under "Global Settings", specify the following protocols. # BEGIN CODE # ... [global] client min protocol = CORE client max protocol = NT1 # ... # END CODE 3. Temporarily stop the "Common Unix Printing System" (CUPS) service. user@host: $ sudo service cups stop 4. Open the CUPS printer configuration file. user@host: $ sudo nano -c /etc/cups/printers.conf 5. Find and modify (or add) the following directive. # BEGIN CODE # ... # UUID ... AuthInfoRequired username,password # This allows the printer service to receive user/pass authentication. # The words "username,password" must be written as is, not as actual user/pass. # ... # END CODE 6. St...

Redirect Apache HTTP to HTTPS in FreeBSD

Image
After enabling HTTPS on the web server in FreeBSD, remote users can be redirected to this secure protocol by automatically rewriting the URL. ========== 1. Log in to "root". Regular users must be part of the "wheel" group in order to do this. user@host: $ su - 2. Open the Apache main configuration file. root@host: # ee /usr/local/etc/apache24/httpd.conf 3. Find and uncomment the following Apache directives. # BEGIN CODE # ... LoadModule rewrite_module libexec/apache24/mod_rewrite.so # Apache rewrite engine Include etc/apache24/Includes/*.conf # Custom configuration files # ... # END CODE 4. Create a custom config file in the "Includes" directory. root@host: # ee /usr/local/etc/apache24/Includes/myrewrite.conf 5. Place the following code in the custom config file. # BEGIN CODE # ... RewriteEngine On # Enables directives for rewriting. RewriteCond %{HTTPS} !=on # Verifies that the connection is not yet in HTTPS. RewriteRule ^/?(.*) https://%{SERVER_NAME}/$...