יום שבת, 25 ביוני 2022

The right way to use rsync

 rsync -avW -LK --progress ./from /to

 

Enable snap mysql-workbench to have access to the network

 sudo snap connect mysql-workbench-community:password-manager-service :password-manager-service

יום שבת, 19 במרץ 2022

Making sure my linux system does not wake up on suspend

Had this annoying problem in my linux Xubuntu 20.04 when putting on suspend the system then starts even though I put it in suspend and sleep.

Using acpitool to turn off wake-up from unnecessary devices.

But the problem the change is not permanent and does not survive a restart.

So I used cron @reboot to make sure it is always off:

@reboot acpitool -W 3 && acpitool -W 9 && acpitool -W 10 && acpitool -W 17 && acpitool -W 63 && acpitool -W 64 && acpitool -W 66 && acpitool -W 68 && acpitool -W 74
 

 


יום חמישי, 17 במרץ 2022

Scanning Local Network for Devices

 nmap -sT 192.168.1.1/24

 

 

יום שבת, 5 במרץ 2022

MySQL Test Timezone Script

 CREATE TABLE tzt(
id MEDIUMINT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY,
ts TIMESTAMP NOT NULL,
dt DATETIME NOT NULL
);

SELECT @@global.time_zone, @@session.time_zone;


SET GLOBAL time_zone = 'Asia/Jerusalem';
SET SESSION time_zone = 'Asia/Jerusalem';

INSERT INTO tzt SET ts='2021-08-22 13:30:00', dt='2021-08-22 13:30:00';

SELECT * FROM tzt\G

SET GLOBAL time_zone = 'America/Sao_Paulo';
SET SESSION time_zone = 'America/Sao_Paulo';


SELECT * FROM tzt\G

rsync backup command

 rsync -avW --progress ./from /to


יום שני, 10 בינואר 2022

Connecting to mysql with TLS 1.2 SSL encrypted connection

In order to be able to connect to MySQL remote server using encrypted connection overt TLS1.2 you will need a .pem certificate of CA.

 You can obtain the certificate here: https://dl.cacerts.digicert.com/DigiCertGlobalRootCA.crt.pem

(DigiCertGlobalRootCA.crt.pem)

Read more here:

https://docs.microsoft.com/en-us/azure/mysql/flexible-server/how-to-connect-tls-ssl

Here is a PHP sample for connection with SSL to MySQL encrypted connection on TLS1.2:

self::$mysqli = mysqli_init();
//self::$mysqli->options(MYSQLI_OPT_SSL_VERIFY_SERVER_CERT, true);
self::$mysqli->ssl_set(NULL, NULL, "DigiCertGlobalRootCA.crt.pem", NULL, NULL);
self::$mysqli->real_connect(host', 'username', 'password', 'database'); // , 3306, MYSQLI_CLIENT_SSL);

//self::$mysqli = new mysqli('hots', 'username', 'password', 'database');   
self::$mysqli->set_charset('utf8');
return self::$mysqli;

Here is the full certificate for MySQL secure connection

    -----BEGIN CERTIFICATE-----
MIIDrzCCApegAwIBAgIQCDvgVpBCRrGhdWrJWZHHSjANBgkqhkiG9w0BAQUFADBh
MQswCQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3
d3cuZGlnaWNlcnQuY29tMSAwHgYDVQQDExdEaWdpQ2VydCBHbG9iYWwgUm9vdCBD
QTAeFw0wNjExMTAwMDAwMDBaFw0zMTExMTAwMDAwMDBaMGExCzAJBgNVBAYTAlVT
MRUwEwYDVQQKEwxEaWdpQ2VydCBJbmMxGTAXBgNVBAsTEHd3dy5kaWdpY2VydC5j
b20xIDAeBgNVBAMTF0RpZ2lDZXJ0IEdsb2JhbCBSb290IENBMIIBIjANBgkqhkiG
9w0BAQEFAAOCAQ8AMIIBCgKCAQEA4jvhEXLeqKTTo1eqUKKPC3eQyaKl7hLOllsB
CSDMAZOnTjC3U/dDxGkAV53ijSLdhwZAAIEJzs4bg7/fzTtxRuLWZscFs3YnFo97
nh6Vfe63SKMI2tavegw5BmV/Sl0fvBf4q77uKNd0f3p4mVmFaG5cIzJLv07A6Fpt
43C/dxC//AH2hdmoRBBYMql1GNXRor5H4idq9Joz+EkIYIvUX7Q6hL+hqkpMfT7P
T19sdl6gSzeRntwi5m3OFBqOasv+zbMUZBfHWymeMr/y7vrTC0LUq7dBMtoM1O/4
gdW7jVg/tRvoSSiicNoxBN33shbyTApOB6jtSj1etX+jkMOvJwIDAQABo2MwYTAO
BgNVHQ8BAf8EBAMCAYYwDwYDVR0TAQH/BAUwAwEB/zAdBgNVHQ4EF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