CentOS 7 updated repo after its EOL

mirrorlist.centos.org doesn’t exists anymore. So, your default repor wwith yum doesn’t work. Try using the following processes, it worked for me, hope this works for others as well.

sed -i s/mirror.centos.org/vault.centos.org/g /etc/yum.repos.d/*.repo
sed -i s/^#.*baseurl=http/baseurl=http/g /etc/yum.repos.d/*.repo
sed -i s/^mirrorlist=http/#mirrorlist=http/g /etc/yum.repos.d/*.repo

Ref:
https://serverfault.com/questions/1161816/mirrorlist-centos-org-no-longer-resolve

Share

XCP-NG few basic command lines- CLI

Run the following command to list VMs and their UUIDs:

xe vm-list resident-on=<uuid_of_host>

Try the shutdown command with force:

xe vm-shutdown uuid=<uuid_of_vm> force=true

Restart the toolstack on the host by using the following command:

xe-toolstack-restart

Restart the host.

shutdown -r now

If the VM is still not shutdown, you might need to destroy the domain. However, the steps given below can cause problems for your VM and should only be done as a last resort.

Read more

Share

Install LetsEncrypt on Debian with Nginx Server

Install Certbot and its Nginx plugin with apt:

sudo apt install certbot python3-certbot-nginx

Certbot provides a variety of ways to obtain SSL certificates through plugins. The Nginx plugin will take care of reconfiguring Nginx and reloading the config whenever necessary. To use this plugin, type the following:

sudo certbot --nginx -d example.com -d www.example.com
Share

Reset XCP-ng root password

The full prodecure can also be found on xcp-ng site.

  • Reboot your XCP-ng into Grub boot menu.
  • Select XCP-ng boot menu entry and press e key to edit boot options.
  • Locate the read-only parameter ro and replace it with rw init=/sysroot/bin/sh.
  • Press Ctrl + X to boot into single-mode.
  • From the Emergency Mode prompt, execute the command chroot /sysroot.
  • Once in single-mode, use passwd command to reset your XCP-ng root password.
  • Reboot XCP-ng by sending Ctrl + Alt + Suppr.
  • If everything went well, you should now be able to login with your new XCP-ng password.
Share

Creating 1:1 NAT using iptables

Its a POC where I needed a 1:1 NAT using  Linux iptables. I used 2 Debian 11 OS for this and here’s the machine IP plans-

  • VM-1: IPTables/NAT Router- 123.45.67.5/24, 123.45.67.6/24 and 192.168.10.5/24
  • VM-2: Backend Server- 192.168.10.6/24 (this VM’s gateway will be 192.168.10.5

On VM-1

Uninstall nftables and its Dependencies

IPtables is being replaced by nftables starting with Debian 10 Buster. Debian 11 comes with nftables framework. To install iptables first we need uninstall nftables and its dependencies. SSH into your server and run the next commands:

# apt-get remove --auto-remove nftables
# apt-get purge nftables

Install IPtables in Debian 11

# apt-get update
# apt-get install iptables

Now we can check the iptables status and list rules. For list all the rules we will use option -L.

Run command:

# iptables -L -v

You will see the output:

As you see on the screenshot just installed iptables firewall and it works. But all chains (INPUT, FORWARD, OUTPUT) are set to ACCEPT, and we have no security rules configured.

Read more

Share

MinIO object storage upload using curl

#!/bin/bash

# Usage: ./minio-upload my-bucket my-file.zip

bucket=$1
file=$2

host=minio.example.com
s3_key=svc_example_user
s3_secret=svc_example_user_password

resource="/${bucket}/${file}"
content_type="application/octet-stream"
date=`date -R`
_signature="PUT\n\n${content_type}\n${date}\n${resource}"
signature=`echo -en ${_signature} | openssl sha1 -hmac ${s3_secret} -binary | base64`

curl -X PUT -T "${file}" \
-H "Host: ${host}" \
-H "Date: ${date}" \
-H "Content-Type: ${content_type}" \
-H "Authorization: AWS ${s3_key}:${signature}" \
https://${host}${resource}

Src:

Share

Debian/Ubuntu font installation using command

Install a font manually by downloading the appropriate .ttf or otf files and placing them into /usr/local/share/fonts (system-wide), ~/.local/share/fonts (user-specific) or ~/.fonts (user-specific). These files should have the permission 644 (-rw-r–r–), otherwise they may not be usable.

Run fc-cache to update the font cache (add -v for verbose output). The above mentioned paths can be customized in the fontconfig configuration file at /etc/fonts/fonts.conf – you can also include subdirectories or links, which is useful if you have a directory of fonts on a separate hard drive (or partition or other location).

If you are installing bit map fonts you might need to enable this with dpkg-reconfigure:

# dpkg-reconfigure fontconfig-config
Share

Install LAMP- Apache, PHP 7.4 with Apache Handler on Debian 12

Well, it’s not perfectly a LAMP stack as MySQL and PHPMYadmin are not covered here. But for someone who needs a backward compatible php edition to work on a modern/latest os built.

Step1: Add PHP repository

We’ll use a bash script to add the repository-

#!/bin/sh
# To add this repository please do:

if [ "$(whoami)" != "root" ]; then
SUDO=sudo
fi

${SUDO} apt-get update
${SUDO} apt-get -y install lsb-release ca-certificates curl
${SUDO} curl -sSLo /tmp/debsuryorg-archive-keyring.deb https://packages.sury.org/debsuryorg-archive-keyring.deb
${SUDO} dpkg -i /tmp/debsuryorg-archive-keyring.deb
${SUDO} sh -c 'echo "deb [signed-by=/usr/share/keyrings/deb.sury.org-php.gpg] https://packages.sury.org/php/ $(lsb_release -sc) main" > /etc/apt/sources.list.d/php.list'
${SUDO} apt-get update

Step-2: Install PHP Modules

Install a few dependencies required by this tutorial with the below-mentioned command:

sudo apt install software-properties-common ca-certificates lsb-release apt-transport-https

Install PHP 7.4:

sudo apt install php7.4

if you want to add multiple extensions then include them in braces, I am going to install “php-mbstring, php-mysql, php-xml, and php-curl” by running the below-mentioned command:

sudo apt install php7.4-mysql php7.4-mbstring php7.4-xml php7.4-curl

Src:

How To Install PHP (8.3, 8.2, 7.4) on Ubuntu 22.04


https://packages.sury.org/php/README.txt

Share

Setup Apache, FastCGI and PHP 7.4 on Ubuntu 20

Prerequisites

Update the installed packages.

apt update

Install the Ondřej PHP repository.

apt install software-properties-commonsudo
add-apt-repository ppa:ondrej/php
apt update

Check that the repositories are correctly installed.

grep ^ /etc/apt/sources.list /etc/apt/sources.list.d/*

Step 1 – Install Apache

apt install apache2

Read more

Share