czwartek, 30 marca 2023

ElasticSearch / OpenSearch: Could not initialize class com.sun.jna.Native

 ElasticSearch or OpenSearch error: 

 fatal error in thread [main], 

exiting

java.lang.NoClassDefFoundError: Could not initialize class com.sun.jna.Native

        at org.opensearch.systemd.Libsystemd.lambda$static$0(Libsystemd.java:47) ~[?:?]


Solution:

mkdir -p /var/lib/opensearch/tmp
chmod 777 /var/lib/opensearch/tmp

edit file: /etc/opensearch/jvm.options

-Djava.io.tmpdir=${OPENSEARCH_TMPDIR}
to
-Djava.io.tmpdir=/var/lib/opensearch/tmp

piątek, 25 lutego 2022

du -sh only given parition (ex root)

 du -h -x -d 1 /


-x = --one-file-system skip directories on different file system

-d = maximum depth

-h = human readable 

/ = partition

środa, 9 lutego 2022

OpenSSL check SSL cli

 OpenSSL check SSL: 

openssl s_client -showcerts -connect server.domain.com:465 smtp


OpenSSL check SSL expiration etc:

openssl s_client -showcerts -connect server.domain.com:465 | openssl x509 

środa, 21 kwietnia 2021

cPanel: An error occurred while attempting to unsuspend “USER”. The user “USER” is not in a suspended state.

 cPanel: An error occurred while attempting to unsuspend “USER”. The user “USER” is not in a suspended state.

Remove broken tasks from: 

rm /var/cpanel/taskqueue/*.json

and

/usr/local/cpanel/scripts/suspendacct USER

/usr/local/cpanel/scripts/unsuspendacct USER

wtorek, 9 marca 2021

myisamchk: error: 140 when opening MyISAM-table 'mysql/user.MYI'

 myisamchk: error: 140 when opening MyISAM-table 'mysql/user.MYI'

Solution:

myisamchk -r -v -f mysql/user WITHOUT EXTENSION

czwartek, 4 lutego 2021

Elasticsearch tmp noexec - change tmp location

Edit

/etc/sysconfig/elasticsearch

put

echo ES_TMPDIR=/var/lib/elasticsearch/tmp

chmod 777 /var/lib/elasticsearch/tmp

wtorek, 26 stycznia 2021

.htaccess limit access to given resource

RewriteCond %{REQUEST_URI} ^(/file/path/file.php).*$


RewriteCond %{REMOTE_ADDR} !=192.168.1.0/24


RewriteCond %{REMOTE_ADDR} !=192.168.*


RewriteRule ^.*$ / [F]

środa, 20 stycznia 2021

Azure App Service + .well-known 404 error

 - create directory .well-known with dot

- create web.config inside of .well-known with

<?xml version="1.0"?>

<configuration>

  

  <system.web>

    <!-- Make directory public. Allow anonymous users access to everything in this directory. -->

    <authorization>

      <allow users="*"/>

    </authorization>

  </system.web>

  

  <system.webServer>

    <!-- Directory only contains plain text files. -->

    <staticContent>

      <mimeMap fileExtension=".*" mimeType="text/plain" />

    </staticContent>

    

    <!-- Only static files are allowed, so remove everything but the StaticFile handler. This also solves the issue with extensionless files returning a 404 Page Not Found. -->

    <handlers>

      <clear />

      <add name="StaticFile" path="*" verb="*" type="" modules="StaticFileModule,DefaultDocumentModule,DirectoryListingModule" scriptProcessor="" resourceType="Either" requireAccess="Read" allowPathInfo="false" preCondition="" responseBufferLimit="4194304" />

    </handlers>

  </system.webServer>

  

</configuration>

Ubuntu force dhcp

 systemctl enable systemd-networkd



cat /etc/systemd/network/20-dhcp.network

[Match]

Name=enp*


[Network]

DHCP=ipv4

wtorek, 14 lipca 2020

czwartek, 5 marca 2020

wtorek, 3 marca 2020

Lock python-requests and other bots in htaccess

Enable mod_version

## Automated HTTP libraries
RewriteCond %{HTTP_USER_AGENT} ^.*(dav.pm/v|libwww-perl|urllib|python-requests|python-httplib2|winhttp.winhttprequest|lwp-request|lwp-trivial|fasthttp|Go-http-client|Java|httplib|httpclient|Zend_Http_Client).*$ [NC]
RewriteRule .* - [F,L]

## Commonly seen in DDoS attacks
RewriteCond %{HTTP_USER_AGENT} ^.*(CtrlFunc|w00tw00t|Apachebench).*$ [NC]
RewriteRule .* - [F,L]

czwartek, 23 stycznia 2020

Sed: remove javascript from files

grep -Ril same.js | xargs sed -i "s/<script type='text\/javascript' src='https:\/\/localhost\/same.js'><\/script>//g"

czwartek, 7 listopada 2019

Sed: remove block of text

Example code:

var gdjfgjfgj235f = 1; var d=document;var s=d.createElement('script'); s.type='text/javascript';
(...)
d.getElementsByTagName('head')[0].appendChild(s);
}

Sed:

sed -i ‘/^var gdjfgjfgj235f/,/^}/d’ $file

sed -i ‘/^d.getElementsByTagName(.*head.*appendChild/,/^}/d’ $file

poniedziałek, 12 sierpnia 2019

cPanel: Failed at step NAMESPACE spawning /usr/bin/mysqld_pre_systemd: Cannot allocate memory

cPanel, mysql error, openvz container

Failed at step NAMESPACE spawning /usr/bin/mysqld_pre_systemd: Cannot allocate memory

error occurs when jailed Apache enabled

check /proc/mounts limits

wtorek, 6 sierpnia 2019

BORG backup: restrict client commands on remote SSH

Add on backup server to .ssh/authorized_keys:

command="borg serve --restrict-to-path /home/USER/REPO.borg",no-pty,no-agent-forwarding,no-port-forwarding,no-X11-forwarding,no-user-rc ssh-rsa KEY

cPanel DNS cluster - force sync zones to cPanel Slave Only from command line

1. Enable DNS cluster
2. Add cPanel Slave Only to MASTER as 'Synchronize changes'
3. Run from command line on master:

/usr/local/cpanel/scripts/dnscluster syncall --full

Check how many zones listed on slave:

[12:07:15 SLAVE root@XXXXXX ~]cPs# /usr/local/cpanel/whostmgr/bin/dnsadmin --action GETZONELIST --localonly|wc -l
1300

piątek, 2 sierpnia 2019

Recreate /boot directory on Centos 7

chroot / rescue / whatever

mv /boot{,.old}
mkdir -p /boot
chmod 0555 /boot
yum reinstall kernel -y
grub2-install /dev/xxx
grub2-mkconfig /boot/grub2/grub.cfg
ln -s /boot/grub2/grub.cfg /etc/grub2.cfg