Go to “Kibana/app/fleet/agents”
Click the 3 dots on the host and select uninstall agent.

Select the command to uninstall and run it on the host.

Finally hit the three dots and unenroll agent.
In this post we are going to setup Exim to add “[External]” to the email subject if it originates from outside of the local domain.
Thanks to Sam for this post. It was extremely helpful.
https://tech.saqr.org/2020/01/for-incoming-email-not-from-our-domain.html
Steps
SSH to the server and create a Exim filter. In cPanel there are in /usr/local/cpanel/etc/exim/sysfilter/options/
. You can name the filter what ever you want.
vi /usr/local/cpanel/etc/exim/sysfilter/options/external_email_warning
Change “incredigeek.com” to your domain name.
You can also change “[External]” to whatever you want to be prepended to the subject.
if
$header_to: contains "@incredigeek.com>"
and $header_from: does not contain "@incredigeek.com>"
and $header_subject: does not contain "[External]"
then
headers add "Old-Subject: $h_subject:"
headers remove "Subject"
headers add "Subject: [External] $h_old-subject"
headers remove "Old-Subject"
endif
Save the file.
Now log into WHM, go to Service Configuration > Exim Configuration Manager > Basic Editor > Filters
At the bottom of the filters, you should see a new “Custom Filter: external_email_filter”
This is the filter you just created. Make sure it is On, and Save changes.
There you go! Any email you receive now that is from an external domain should now have “[External]”, or whatever you specified, prepended to the subject.
If you run into any errors, try reviewing the panic log to see if there are any syntax errors.
You can use tail to follow the panic log to verify you have all the syntax correct.
tail /var/log/exim_paniclog -f
The PowerDNS Recursor started supporting YAML for configs in version 5.0.0. YAML is the default as of 5.2.0. You can still use the old config if --enable-old-settings
is provided as a command line option when starting PowerDNS. If that option is not being used, and you are using the old config, you will experience the following errors.
msg="Old-style settings syntax not enabled by default anymore. Use YAML or enable with --enable-old-settings on the command line" subsystem="config" level="0" prio="Error" tid="0" ts="1732025541.126" configname="/etc/pdns-recursor/recursor.conf"
msg="YAML config found, but error occurred processing it" error="invalid type: string \"allow-from=127.0.0.0/8, 10.0.0.0/8, 192.168.0.0/16", expected struct Recursorsettings at line 17 column 1" subsystem="config" level="0" prio="Error" tid="0" ts="1732025541.817" configname="/etc/pdns-recursor/recursor.conf"
Fortunately, this is an easy fix.
rec_control
.The rec_control
command can convert our old style config to a YAML config. This should automatically pull the default config in /etc/pdns-recursor/recursor.conf
.
rec_control show-yaml
Save output to /etc/pdns-recursor/recursor.yml
We can remove the old config by renaming it, or deleting it.
mv /etc/pdns-recursor/recursor.conf /etc/pdns-recursor/recursor.conf.oldstyle
Or
rm /etc/pdns-recursor/recursor.conf
Start the pdns-recursor
service using the systemctl
command.
sudo systemctl start pdns-recursor
Verify there are no errors
sudo systemctl status pdns-recursor
Further Reading.
Here are a few ways you can migrate emails without knowing the IMAP credentials.
Some email services allow you to use the administrator password to sign into any email account. This allows you to move emails without knowing the users password.
You can refer to this FAQ on the imapsync website.
https://imapsync.lamiral.info/FAQ.d/FAQ.Admin_Authentication.txt
Disclaimer:
This option will only work if you have ftp/ssh/filesystem access.
Depending on email volume, you could miss emails that arrive during the transition.
If possible, it is recommended to use something like imapsync.
There could be format issues if the two email servers use different mailbox formats and/or email server software.
Emails are usually stored in the users home directory. Depending on the hosting provider, it could be /mail
or ~/mail
You can zip up the mail directory and then unzip on the target server. This would only work if you have access to the filesystem. Create your email accounts before unzipping.
You could transfer the passwd and shadow files to keep the email passwords the same. Again, create the email addresses on the target server first and then either overwrite, or merge the differences between the shadow and passwd files.
For example, on cPanel servers, the mail directory is in ~/mail
and the shadow and passwd files are in ~/etc/DOMAIN.COM
If you are logged in as root, you will need to change ~/
to /home/USER/
substituting USER for the actual cPanel user.
You can import and export emails using the RoundCube webmail interface. However, the export is limited to one. message. at. a. time. This could work for a handful of messages, but can get quite tedious if you have a large number of emails.
The following are the steps needed to install a PowerDNS recursor on RHEL, Fedora, Rocky Linux, or AlmaLinux
Install from package manager with
yum install pdns-recursor
Allow DNS through Firewall
sudo firewall-cmd --add-service=dns --permanent
Configure the `/etc/pdns-recursor/recursor.conf` file. The local-address is the DNS recursor, the allow-from, are the addresses you would like to allow access to
local-address=192.0.1.2
allow-from=192.0.0.0/16, 10.0.0.0/8
Start and enable the `pdns-recursor` service
systemctl enable --now pdns-recursor
[WARNING]: Unhandled error in Python interpreter discovery for host localhost: Expecting value: line 1
column 1 (char 0)
https://github.com/ansible/ansible/issues/83357
Ansible 2.17 moved to using Python 3.7. This causes issues with systems that use Python 3.6 (i.e., RHEL 8 based distros). Unfortunately, you can’t just upgrade Python either, as 3.6 is used in system tools such as DNF/YUM.
There are two options.
Ansible 2.16 should be the default installed version on RHEL 8 based distros.
Info on the xc backdoor
https://www.openwall.com/lists/oss-security/2024/03/29/4
https://tukaani.org/xz-backdoor/
Kostas on Twitter posted a helpful one-liner to check the xz version without running the actual command.
https://twitter.com/kostastsale/status/1773890846250926445
Versions 5.6.0 and 5.6.1 are backdoored.
The following Bash commands were taken and modified from the above Twitter link
Here is a one liner that will check the version of xz binaries and return if they are safe or vulnerable. You’ll need to run this in a Bash shell. May have issues in sh.
for xz_p in $(type -a xz | awk '{print $NF}' ); do if ( strings "$xz_p" | grep "xz (XZ Utils)" | grep '5.6.0\|5.6.1' ); then echo $xz_p Vulnerable; else echo $xz_p Safe ; fi ; done
Here are two different Ansible Playbooks to check if the xz package(s) are backdoored.
This one uses the above Bash commands to check the xz binaries.
---
- name: Check if XZ tools are compromised
# https://twitter.com/kostastsale/status/1773890846250926445
hosts: all
tasks:
- name: Run Bash command
shell :
for xz_p in $(type -a xz | awk '{print $NF}' ); do
if ( strings "$xz_p" | grep "xz (XZ Utils)" | grep '5.6.0\|5.6.1' );
then echo $xz_p Vulnerable!;
else
echo $xz_p Safe ;
fi ;
done
args:
executable: /bin/bash
register: result
- name: Show output
ansible.builtin.debug:
msg: "{{ result.stdout_lines }}"
The following playbook uses the package manager to check the xz version. On RHEL/Fedora this is the xc package. On Debian/Ubuntu, it is part of the liblzma5 package.
---
- name: Check if XZ tools are compromised
hosts: all
tasks:
- name: Collect package info
ansible.builtin.package_facts:
manager: auto
- name: Check if liblzma5 is vulnerable (Ubuntu/Debian)
ansible.builtin.debug:
msg: "Installed version of liblzma5/xz: {{ ansible_facts.packages['liblzma5'] | map(attribute='version') | join(', ') }} Vulnerable!"
when: ('liblzma5' in ansible_facts.packages) and (ansible_facts.packages['liblzma5'][0].version.split('-')[0] is version('5.6.0', '==') or ansible_facts.packages['liblzma5'][0].version.split('-')[0] is version('5.6.1', '=='))
- name: Check if xz is vulnerable (RHEL/Fedora/Rocky/Alma)
ansible.builtin.debug:
msg: "Installed version of xz: {{ ansible_facts.packages['xz'] | map(attribute='version') | join(', ') }} is vulnerable"
when: ('xz' in ansible_facts.packages) and (ansible_facts.packages['xz'][0].version is version('5.6.0', '==') or ansible_facts.packages['xz'][0].version is version('5.6.1', '=='))
Using ls
to parse file names is not recommended for multiple reasons
https://mywiki.wooledge.org/ParsingLs
Let’s say we have a directory with two files in it.
Helloworld.txt
Hello, world.txt
Now we want to loop over the files. If we use ls
in our for loop,
for file in $(ls); do echo "$file" ; done
We receive the following output
Hello,
world.txt
Helloworld.txt
The space in “Hello, world.txt” is translated as a new line. This could break our script.
Here is a better way
for file in * ; do echo "$file" ; done
Helpful links
Install rsyslog
dnf install rsyslog -y
Edit the journald log.
vi /etc/systemd/journald.conf
Add, enable, or modify the following lines.
ForwardToSyslog=yes MaxLevelSyslog=debug
Enable and start rsyslog
systemctl enable rsyslog
systemctl start rsyslog
These steps are taken from the following link. They have other guides for hardening Ubuntu, Debian etc.
https://www.sshaudit.com/hardening_guides.html#rocky9
You will need to become the root user, use either su – or sudo -i
First we need to regenerate the RSA and ED25519 keys
rm /etc/ssh/ssh_host_*
ssh-keygen -t rsa -b 4096 -f /etc/ssh/ssh_host_rsa_key -N ""
ssh-keygen -t ed25519 -f /etc/ssh/ssh_host_rsa_key -N ""
Next, remove the small Diffie-Hellman moduli. The moduli file contains prime numbers and generators. Removing the smaller numbers should help increase security as it makes attempting to factor the private keys harder.
awk '$5 >= 3071' /etc/ssh/moduli > /etc/ssh/moduli.safe
mv /etc/ssh/moduli.safe /etc/ssh/moduli
We can now specify which key exchange, ciphers, and algorithms to use.
Add the following to “/etc/crypto-policies/back-ends/opensshserver.config”
# Restrict key exchange, cipher, and MAC algorithms, as per sshaudit.com
# hardening guide.
KexAlgorithms sntrup761x25519-sha512@openssh.com,curve25519-sha256,curve25519-sha256@libssh.org,gss-curve25519-sha256-,diffie-hellman-group16-sha512,gss-group16-sha512-,diffie-hellman-group18-sha512,diffie-hellman-group-exchange-sha256
Ciphers chacha20-poly1305@openssh.com,aes256-gcm@openssh.com,aes128-gcm@openssh.com,aes256-ctr,aes192-ctr,aes128-ctr
MACs hmac-sha2-256-etm@openssh.com,hmac-sha2-512-etm@openssh.com,umac-128-etm@openssh.com
HostKeyAlgorithms sk-ssh-ed25519-cert-v01@openssh.com,ssh-ed25519-cert-v01@openssh.com,rsa-sha2-512-cert-v01@openssh.com,rsa-sha2-256-cert-v01@openssh.com,sk-ssh-ed25519@openssh.com,ssh-ed25519,rsa-sha2-512,rsa-sha2-256
RequiredRSASize 3072
CASignatureAlgorithms sk-ssh-ed25519@openssh.com,ssh-ed25519,rsa-sha2-512,rsa-sha2-256
GSSAPIKexAlgorithms gss-curve25519-sha256-,gss-group16-sha512-
HostbasedAcceptedAlgorithms sk-ssh-ed25519-cert-v01@openssh.com,ssh-ed25519-cert-v01@openssh.com,sk-ssh-ed25519@openssh.com,ssh-ed25519,rsa-sha2-512-cert-v01@openssh.com,rsa-sha2-512,rsa-sha2-256-cert-v01@openssh.com,rsa-sha2-256
PubkeyAcceptedAlgorithms sk-ssh-ed25519-cert-v01@openssh.com,ssh-ed25519-cert-v01@openssh.com,rsa-sha2-512-cert-v01@openssh.com,rsa-sha2-256-cert-v01@openssh.com,sk-ssh-ed25519@openssh.com,ssh-ed25519,rsa-sha2-512,rsa-sha2-256
Finally, restart the ssh server
systemctl restart sshd
Other helpful links