Posts

Showing posts with the label Debian

https://www.vultr.com

The Everywhere Cloud

Deploy an instance.
Accelerate your application.


Navigating IBM i with VS Code

Image
The following procedure shows how to connect to an IBM i (AS400) server and explore it using the Visual Studio Code Integrated Development Environment. ========== 1. INSTALLATION 1.1. Download and install the Visual Studio Code IDE. https://code.visualstudio.com/ 2. PREPARATION 2.1. On the VS Code menu, go to [ Go -> Go to File... ] or press Ctrl+P, and input the command below to install the "Code for IBM i" extension. ext install HalcyonTechLtd.code-for-ibmi 2.2. On the left sidebar, click on the IBM i icon to show the IBM i Servers panel and click on the plus "+" sign at the top to create a connection. 2.3. On the Login tab, input the following IBM i server details and click [ Connect ]. Connection Name: (just a placeholder name for easy identification) Host or IP Address: (network address of IBM i server)   SSH Port: 22 (usually) Username: (username on IBM i server) Password: (password on IBM i server) 3. UTILIZATION 3.1. User Library List Libraries are requir...

Developing ESP32 with Eclipse on Linux

Image
The following procedure shows how to build ESP32 microcontroller projects with the Eclipse Integrated Development Environment on Debian-based Linux distributions. ========== 1. INSTALLATION 1.1. Install Espressif's IoT Development Framework for ESP32 with the RTOS SDK. https://www.sysadsim.com/2022/09/using-esp-idf-on-linux.html 1.2. Download and install the Eclipse IDE. https://www.sysadsim.com/2022/09/installing-eclipse-ide-on-linux.html 2. PREPARATION 2.1. On the Eclipse IDE, click on the following to install ESP-IDF plugins for Eclipse. [ Help -> Install New Software -> Add... ] Name: Espressif IDF Plugin for Eclipse Location: https://dl.espressif.com/dl/idf-eclipse-plugin/updates/latest/ Click [ Add ]. Go to [ Espressif IDF dropdown ]. Check [ CMake Editor ]. Check [ Espressif IDF Plugins for Eclipse ]. Click [ Next -> Accept license terms -> Finish ]. Wait for plugins download and installation to complete. Click [ Select All -> Trust ] if asked to trust some so...

Developing ESP8266 with Eclipse on Linux

Image
The following procedure shows how to build ESP8266 microcontroller projects with the Eclipse Integrated Development Environment on Debian-based Linux distributions. ========== 1. INSTALLATION 1.1. Install Espressif's IoT Development Framework for ESP8266 with the RTOS SDK. https://www.sysadsim.com/2022/09/using-esp8266-rtos-sdk-on-linux.html 1.2. Download and install the Eclipse IDE. https://www.sysadsim.com/2022/09/installing-eclipse-ide-on-linux.html 2. PREPARATION 2.1. On the Eclipse IDE, click on the following to open the target ESP8266 project folder and choose its toolchain. [ File -> Import... ] [ C/C++ -> Existing Code as Makefile Project -> Next ] [ Existing Code Location -> Browse... ] Example: ~/esp/ESP8266_RTOS_SDK/examples/get-started/hello_world [ Toolchain for Indexer Settings -> Cross GCC -> Finish ] 2.2. Set up the project's properties. [ Project Explorer tab -> Right-click on project name -> Properties ] 2.2.1. C/C++ General Indexer Go ...

Developing ESP32 with VS Code on Linux

Image
The following procedure shows how to build ESP32 microcontroller projects with the Visual Studio Code Integrated Development Environment on Debian-based Linux distributions. ========== 1. INSTALLATION 1.1. Install Espressif's IoT Development Framework for ESP32 with the RTOS SDK. https://www.sysadsim.com/2022/09/using-esp-idf-on-linux.html 1.2. Download and install the Visual Studio Code IDE. https://code.visualstudio.com/ 2. PREPARATION 2.1. On the VS Code menu, go to [ File -> Open Folder... ] and open the target ESP32 project folder. Example: ~/esp/esp-idf/examples/get-started/hello_world 2.2. On its bottom panel, click on the Terminal tab. This will automatically change to the location of the opened folder. 2.3. Temporarily add the ESP-IDF toolchain to the shell path. user@host: $ . ~/esp/esp-idf/export.sh or user@host: $ source ~/esp/esp-idf/export.sh 2.4. Verify if the toolchain has been added to the shell path. user@host: $ echo $PATH 3. UTILIZATION 3.1. Maximize the bott...

Developing ESP8266 with VS Code on Linux

Image
The following procedure shows how to build ESP8266 microcontroller projects with the Visual Studio Code Integrated Development Environment on Debian-based Linux distributions. ========== 1. INSTALLATION 1.1. Install Espressif's IoT Development Framework for ESP8266 with the RTOS SDK. https://www.sysadsim.com/2022/09/using-esp8266-rtos-sdk-on-linux.html 1.2. Download and install the Visual Studio Code IDE. https://code.visualstudio.com/ 2. PREPARATION 2.1. On the VS Code menu, go to [ File -> Open Folder... ] and open the target ESP8266 project folder. Example: ~/esp/ESP8266_RTOS_SDK/examples/get-started/hello_world 2.2. On its bottom panel, click on the Terminal tab. This will automatically change to the location of the opened folder. 2.3. Temporarily add the ESP8266 IDF toolchain to the shell path. user@host: $ . ~/esp/ESP8266_RTOS_SDK/export.sh or user@host: $ source ~/esp/ESP8266_RTOS_SDK/export.sh 2.4. Verify if the toolchain has been added to the shell path. user@host:...

Using the ESP-IDF on Linux

Image
The following procedure shows how to use Espressif's Internet-of-Things Development Framework for ESP32 microcontrollers on Debian-based Linux distributions. The ESP-IDF uses the Real-Time Operating System (RTOS) Software Development Kit (SDK). ========== 1. INSTALLATION 1.1. Update package indexes and install the prerequisites. user@host: $ sudo apt-get update user@host: $ sudo apt-get install bison libbison-dev user@host: $ sudo apt-get install cmake user@host: $ sudo apt-get install flex libfl-dev libfl2 user@host: $ sudo apt-get install git user@host: $ sudo apt-get install gperf user@host: $ sudo apt-get install libncurses-dev user@host: $ sudo apt-get install python3 python3-dev python3-pip python3-venv python3-wheel 1.2. Clone the development repository from GitHub. This will download to a directory with the same name. user@host: $ mkdir esp user@host: $ cd esp user@host: $ git clone --recursive https://github.com/espressif/esp-idf.git 1.2.1. For specific releases, clone the...

Using the ESP8266 RTOS SDK on Linux

Image
The following procedure shows how to use Espressif's Real-Time Operating System Software Development Kit for ESP8266 microcontrollers on Debian-based Linux distributions. ========== 1. INSTALLATION 1.1. Update package indexes and install the prerequisites. user@host: $ sudo apt-get update user@host: $ sudo apt-get install bison libbison-dev user@host: $ sudo apt-get install cmake user@host: $ sudo apt-get install flex libfl-dev libfl2 user@host: $ sudo apt-get install git user@host: $ sudo apt-get install gperf user@host: $ sudo apt-get install libncurses-dev user@host: $ sudo apt-get install python3 python3-dev python3-pip python3-venv python3-wheel 1.2. Clone the repository from GitHub. This will download to a directory with the same name. user@host: $ mkdir esp user@host: $ cd esp user@host: $ git clone --recursive https://github.com/espressif/ESP8266_RTOS_SDK.git 1.3. Install the Python packages required by the ESP8266 Internet-of-Things Development Framework. user@host: $ cd E...

Installing the Eclipse IDE on Linux

Image
The following procedure shows how to quickly install the Eclipse Integrated Development Environment on desktop Linux distributions. ========== 1. Download the Eclipse tarball at [ https://www.eclipse.org/downloads/ ]. 2. Open a terminal and extract the installer folder. user@host: $ tar -xf eclipse-inst-jre-linux64.tar.gz 3. Run the installer to launch the graphical user interface. user@host: $ cd eclipse-installer user@host: $ ./eclipse-inst 4. On the GUI, choose the desired package. 4.1. For C/C++ programming, select [ Eclipse IDE for Embedded C/C++ Developers ]. 4.1.1. Use the suggested defaults and click [ Install ]. 4.1.2. When the installation is finished, click [ Launch ]. 4.1.3. Use the suggested Workspace and click [ Launch ]. ==========

Monitoring network traffic with tcpdump

Image
The following procedure demonstrates how to use tcpdump to sniff and log packets going in and out of a machine's network interfaces. ========== 1. Identify the network interfaces available. user@host: $ tcpdump --list-interfaces 1.wlp6s0 [Up, Running] 2.lo [Up, Running, Loopback] 3.any (Pseudo-device that captures on all interfaces) [Up, Running] 4.enp5s0 [Up] 2. Set the sniffing tool to listen on a network interface for packets and send the output to a file for easy review later. 2.1. To and from a target port, such as HTTP, regardless of host. user@host: $ sudo tcpdump -A -i any -l -s 0 -vvv tcp port 80 > mytcpdumpout.txt 2>&1 2.2. To and from a target host, regardless of port. user@host: $  sudo tcpdump -A -i any -l -s 0 -vvv host nameOfMachine > mytcpdumpout.txt 2>&1 2.3. The flags used to adjust the behavior of tcpdump are as follows. [ -A ] prints packets in ASCII format and make them readable, excluding data link layer headers. [ -i any ] c...

Accessing the GlobalProtect VPN via Terminal

Image
The following procedure demonstrates how to connect to the GlobalProtect VPN via command-line terminals. ========== 1. Install openconnect (at least version 8) and dnsmasq. 1.1. Debian-based Linux user@host: $ sudo apt-get update user@host: $ sudo apt-get install openconnect dnsmasq 2. Make a simple shell script to automate the login. #!/bin/sh #BEGIN CODE with the shebang above. user=`whoami`; if [ $user != "root" ]; then echo "sudo required"; exit; fi echo -n "VPN_PASSWORD" | sudo openconnect --protocol=gp --user=VPN_USERNAME --passwd-on-stdin https://VPN_DOMAIN_NAME #END CODE 3. Save the shell script and execute. 3.1. Using the shell command. user@host: $ sh myshellscript.sh 3.2. By itself after changing the mode to executable. user@host: $ chmod +x myshellscript.sh user@host: $ ./myshellscript.sh ==========

Using cURL for response timing

Image
cURL is a command-line tool that connects to a uniform resource locator (URL) for data transfer. Although this tool is commonly used to quickly check if websites are up and running, it can also be used to time the response of services. This may help administrators gather data for analysis to match against baseline response times for performance tuning. cURL has many options or flags available to adjust its behavior. For the purpose of timing, the following flags shall be utilized. [ -k ] tells cURL to disable peer verification of the SSL/TLS certificate. This is useful for connecting to URLs that have  self-signed certificates . [ -s ] tells cURL to operate in silent mode. This suppresses standard error messages and the progress meter. [ -o /dev/null ] tells cURL to dump its standard output to the null device. All messages are effectively discarded and no output file is produced. [ -w '%{time_total}\n' ] tells cURL to write the declared variables to standard output after all tr...

Installing Node.js on Linux

Image
Node.js is a runtime environment that allows JavaScript to be executed directly on the operating system. This enables the use of JavaScript to develop server-side applications. In some Linux distributions, the Node.js implementation may not be properly maintained and may lag from the releases of its official website. The following procedure shows how to manually acquire and install Node.js in order to have the most recent packages. ========== 1. Download the desired Node.js version. 1.1. Node.js x64 and other 64-bit Long-term Support (LTS) https://nodejs.org/en/download/ user@host: $ wget https://nodejs.org/dist/v [ ersionNum ] /node-v [ ersionNum ] -linux-[CPU64].tar.xz user@host: $ tar -xf node-v [ ersionNum ] -linux-[CPU64].tar.xz user@host: $ cd node-v [ ersionNum ] -linux-[CPU64] 1.2. Node.js x64 and other 64-bit previous LTS https://nodejs.org/download/release/ user@host: $ wget https://nodejs.org/download/release/latest-v [ ersionMaj ].x /node-v[ersionNum]-linux-[C...

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...

Enabling REST Apps in Home Assistant

Image
The following procedure shows how to make Home Assistant communicate periodically [ every thirty (30) seconds, by default ] with other endpoints like remote devices or web services. This is made possible by the polling mechanism of its REST "sensor" platform. By default, the "sensor" polls those endpoints for new data every thirty seconds. ========== 1. Log in as the system account (-u), with $HOME "bin" included in $PATH (-i). user@host: $ sudo -i -u homeassistant 2. Go to the directory containing the YAML configuration files. user@host: $ cd ~/.homeassistant 3. BACK UP the main YAML configuration file. user@host: $ cp configuration.yaml configuration_yaml.back 4. Open the main YAML configuration file. user@host: $ nano configuration.yaml 5. Add the following YAML lines and save the file. # BEGIN CODE # ... sensor:   - platform: rest     name: "Dyn Check IP"     resource: http://checkip.dyn.com     method: GET...

Enabling HTTPS in Home Assistant

Image
The following procedure activates HTTPS for the Home Assistant server. The secure protocol uses TLS/SSL certificates to encrypt the data transferred between user and server. Although it is possible to make this home automation system, whether in  Linux or  FreeBSD , accessible over the Internet, Home Assistant is usually operated within private networks, either physical or virtual. In this case, self-signed certificates may be acceptable to use and quicker to deploy. ========== 1. Log in as the system account. 1.1. Linux, with $HOME "bin" included in $PATH (-i) of system account (-u). user@host: $ sudo -i -u homeassistant 1.2. FreeBSD, coming from "root" superuser. root@host: # su - homeassistant 2. Go to the Home Assistant configuration directory. user@host: $ cd ~/.homeassistant 3. Make a directory for SSL certificates. user@host: $ mkdir ssl 4. Ensure that only the system account and members of its group can access the directory. user@host:...

Running Home Assistant on Linux 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. The following procedure shows how to run Home Assistant Core on common Debian-based Linux servers, in either physical or virtual machines. ========== 1. PREPARING THE SERVER 1.1. Update the package list and upgrade the existing packages. user@host: $ sudo apt-get update && sudo apt-get dist-upgrade -y 1.2. Install Python and required packages. user@host: $ sudo apt-get install python3 python3-dev python3-venv libffi-dev libssl-dev autoconf 1.3. Create a system account (-r) with a dedicated home directory (-m). user@host: $  sudo useradd -r -m homeassistant 1.3.1. If groups for hardware input/output are present, append the system account. Else, skip this step for now. user@host: $ sudo usermod -a -G dialout,gpio,i2c homeassistant 1.4. Ensure that only the system account and members of its group...

Running Linux Commands at Startup

Image
The following procedure enables Linux 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 can also be done on the FreeBSD crontab , with some slight changes to account for the behavior of other shells. ========== 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 2>&1 & # "> /dev/null" discards standard output by redirecting to the null device. # "2>&1" redirects standard error to standard output. # Terminating with "&" executes the command in the background. # END CODE 3. Save and exit crontab, then reboot the machine. ==========

Zeroconf Networking in Linux using Avahi

Image
The following procedure enables Linux machines to talk to each other using host names through zero-configuration (zeroconf) networking, made possible by the Multicast DNS (mDNS) protocol on link-local address IPv4 224.0.0.251 (or IPv6 ff02::fb) port 5353/UDP. This allows the ".local" top-level domain to be appended to the host name at run-time, turning it into a fully-qualified domain name (FQDN) accessible in the local area network (LAN). ========== 1. Update the package list and upgrade the existing packages. user@host: $ sudo apt-get update && sudo apt-get dist-upgrade -y 2. Install Avahi. user@host: $ sudo apt-get install avahi-daemon avahi-utils 3. Test the ".local" domain. user@host: $ ping hostname.local ========== This is particularly useful in a LAN environment where Linux servers and devices operate as an integrated computing cluster. Units can then be added or removed as needed and still communicate continuously since no manual IP...

Self-Signed Certs for Apache in Debian-based Linux

Image
The following procedure shows how to apply self-signed certificates to the Apache web server in Debian-based Linux distributions. After creating and installing  the TLS/SSL certificate/key pair, they can be utilized to  secure Debian-based Linux web services  with encryption during the development and testing process. It is important to keep in mind that self-signing may be deemed UNTRUSTWORTHY in a production environment. ========== 1. Go to the directory containing the Apache site configuration files. user@host: $ cd /etc/apache2/sites-available 2.  BACK UP the default HTTPS configuration file for the secure site. user@host: $ sudo cp default-ssl.conf default-ssl-conf.back 3. Open the default HTTPS configuration file. user@host: $ sudo nano default-ssl.conf 4. Find and modify the following Apache directives. # BEGIN CODE # ... SSLCertificateFile /etc/ssl/certs/myserver.crt # The self-signed certificate. SSLCertificateKeyFile /...

Making Self-Signed Digital Certificates

Image
The need for TLS/SSL certificates may arise when developing server projects that need encryption, like the Apache web server on  Debian-based  or Red Hat-based Linux distributions, on the  FreeBSD  operating system, and the Home Assistant  home automation system. The following procedure shows how to create and install self-signed certificates, if acquiring them from a Certificate Authority (CA) is either too expensive or too complicated. It is important to keep in mind, however, that self-signing may be deemed UNTRUSTWORTHY in a production environment. ========== 1. Create the certificate and key. 1.1.  [OPTION A] One-step process, skipping the Certificate Signing Request (CSR). user@host: $  openssl req -new -x509 -days 36500 -nodes -keyout server.key -out server.crt 1.2.  [OPTION B] Separate CSR for submission to CAs, if planning to legitimize later on. 1.2.1. Generate keys for the CSR. user@host:...