Postingan

Menampilkan postingan dari Januari, 2019

PostgreSQL UPSERT

Example SQL Syntax: INSERT INTO student (id, name)     VALUES (5, 'Nasohi Ciptandani')     ON CONFLICT (id) DO UPDATE SET name = EXCLUDED.name; Example Node.js code queries.js file:    const Pool = require('pg').Pool    const pool = new Pool({     user: 'monitoring',     host: 'localhost',     database: 'monitoring',     password: 'p4ssw0rd',     port: 5432,    })      pool.query("DELETE FROM linux_server_status", (error, results) => {      console.log(error, results);   });   const createLinux = (request, response) => {    const {hostname, ip, os, hdd_total, hdd_used, hdd_free, mem_total, mem_free, mem_used, core } = request.body    const now = new Date();    pool.query('INSERT INTO linux_server_status (hostname, ip, os, hdd_total, hdd_used, hdd_free, mem_total, mem_free, mem_used, co...

Basic API Server using Node.js Express Body-Parser

Langkah-langkah: 1. Install Node.js ( https://nodejs.org/en/download/ ) 2. #mkdir my-project && cd my-project 3. #npm init 4. #npm install express --save 5. #npm install body-parser --save Berikut contoh code nya dengan contoh nama file server.js  var express = require("express");  var myParser = require("body-parser");  var app = express();    app.use(myParser.urlencoded({extended : true}));    app.use(myParser.json());    app.post(" /register ", function(request, response) {    console.log(request.body. username );    console.log(request.body. email );    response.send(" OK ");  });  app.listen( 3000 ); 6. Menjalankan code diatas dengan #node server.js 7. Contoh mengirim data dengan format JSON dengan perintah curl #curl -H "Content-Type: application/json" -XOST -d '{"username":"nasohi","email":"nasohi@ciptandani.com"}' http://107.102.182.127:3000/regi...

How to Change Speed and Duplex of Ethernet card in Linux

Use ethtool Install #apt-get install ethtool Example: #ethtool eth0 #ethtool bond0 Change the Speed and Duplex settings #ethtool -s eth0 autoneg on #ethtool -s eth0 speed 10 duplex half autoneg off #ethtool -s eth0 speed 100 duplex full autoneg off Manual #man ethtool

Configure Postfix to use Gmail as a Mail Relay on Fedora

Summary: #dnf update && dnf install postfix cyrus-sasl cyrus-sasl-plain mailx #vi /etc/postfix/sasl_passwd [smtp.gmail.com]:587    username@gmail.com:password #chmod 600 /etc/postfix/sasl_passwd #vi /etc/postfix/main.cf Add or modify the following values: relayhost = [smtp.gmail.com]:587 smtp_use_tls = yes smtp_sasl_auth_enable = yes smtp_sasl_security_options = smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd smtp_tls_CAfile = /etc/ssl/certs/ca-bundle.crt #postmap /etc/postfix/sasl_passwd #systemctl restart postfix.service https://myaccount.google.com/lesssecureapps #mail -s "Subject Here" recipient@domain.com < textfile or #telnet localhost 25 mail from: rcpt to:  data your_messages . quit Troubleshooting: journalctl -u postfix

Simple install Laravel di Debain

Percobaan saya menggunakan Debian 9 Berikut rangkuman step by step nya, buat sekedar catatan, untuk lebih lengkapnya bisa di crosscheck dengan website/blog tutorial lain sudo apt-get update  sudo apt-get upgrade sudo apt-get install curl Install PHP dan kebutuhan PHP modules untuk Laravel sudo apt-get install php-cli php-gd php-mbstring php-mcrypt php-zip php-opcache php-xml Install Composer Composer adalah dependency manager untuk PHP sudo curl -sS https://getcomposer.org/installer | php mv composer.phar /usr/local/bin/composer Install Laravel sudo composer create-project --prefer-dist laravel/laravel my_app cd my_app php artisan serve Laravel development server started: <http://127.0.0.1:8000> Untuk listen di IP lain bisa menggunakan perintah berikut: php artisan serve --host=192.168.100.100 Kalau sudah muncul seperti diatas Laravel sudah bisa digunakan dengan konfigurasi diatas,  agar laravel bisa diakses melalui Domain,IP,HTTP/HTTPS maka ...

OpenLDAP new second domain or multiple DIT

OS: Debian 9.6 Referensi #slapcat -n0 newdit.ldif dn: olcDatabase={2}mdb,cn=config objectClass: olcDatabaseConfig objectClass: olcMdbConfig olcDatabase: {2}mdb olcDbDirectory: /var/lib/ldap/ olcSuffix: dc=nixskill,dc=net olcAccess: {0}to attrs=userPassword,shadowLastChange by self write by anonymous auth by dn="cn=admin,dc=nixskill,dc=net" write by * none olcAccess: {1}to dn.base="" by * read olcAccess: {2}to * by dn="cn=admin,dc=nixskill,dc=net" write by * read olcLastMod: TRUE olcRootDN: cn=admin,dc=nixskill,dc=net olcRootPW: Skill39 #ldapadd -Y EXTERNAL -H ldapi:/// -f newdit.ldif newdc.ldif dn: dc=nixskill,dc=net objectClass: top objectClass: dcObject objectClass: organization o: nixskill.net dc: nixskill #ldapadd -x -D cn=admin,dc=nixskill,dc=net -W -f newdc.ldif newou.ldif dn: ou=tkj,dc=nixskill,dc=net ...

Cara install OpenLDAP

OS: GNU/Linux Debian 9.6 Hostname: instance-1 IP: 104.148.0.1 Hosts: /etc/hosts 104.148.0.1 luxskill.net instance-1 Install: slapd ldap-utils Edit: root@instance-1:~# cat /etc/ldap/ldap.conf  # # LDAP Defaults # # See ldap.conf(5) for details # This file should be world readable but not world writable. BASE    dc=luxskill,dc=net URI     ldap://luxskill.net ldap://luxskill.net:666 #SIZELIMIT      12 #TIMELIMIT      15 #DEREF          never # TLS certificates (needed for GnuTLS) #TLS_CACERT     /etc/ssl/certs/ca-certificates.crt root@instance-1:~# vi base.ldif # create new # change to your own suffix for the field [dc=luxskill,dc=net] dn: ou=itnsa,dc=luxskill,dc=net objectClass: organizationalUnit ou: itnsa root@instance-1:~# ldapadd -x -D cn=admin,dc=luxskill,dc=net -W -f base.ldif Check: root@instance-1:~# slapcat root@instance-1:~# ldapsearc...

Hal-hal yang perlu diperhatikan dalam belajar konfigurasi system ITNSA

Prerequisite: Hal-hal(konsep,dasar konfigurasi) yang diperlukan sebelum belajar konfigurasi system ITNSA. Requirement: Hardware & system infrastructure. Environment: Hostname. IP Address. OS version. Software version. Username. Password. File/folder name. URL. Firewall. Untuk environment sesuaikan dengan project anda Note: Ada yang cuma liat script konfigurasi tanpa penjelasan paham, ada yang perlu dikasih penjelasan, ada juga yang perlu membaca konsep terlebih dahulu, intinya belajar itu bertahap dan cross check antar berbagai sumber belajar.

Cara install MariaDB di Debian 9

Untuk install software database MariaDB cukup mudah, berikut langkah-langkahnya: Update debian #apt-get update Install paket software MariaDB #apt-get install mariadb-server Enable mysql_native_password plugin #mysql -u root USE mysql; UPDATE user SET plugin='mysql_native_password' WHERE User='root'; FLUSH PRIVILEGES; exit systemctl restart mysql.service Initial setting MariaDB #mysql_secure_installation Ikuti hal-hal yang perlu disetting Setelah selesai MariaDB siap digunakan.

Rangkuman Install Database PostgreSQL di Centos7

Configure Yum Repository #rpm -Uvh https://yum.postgresql.org/11/redhat/rhel-7-x86_64/pgdg-centos11-11-2.noarch.rpm Repository info: https://yum.postgresql.org/repopackages.php#pg11 Install PostgreSQL11 #yum install postgresql11-server Initialize PGDATA #/usr/pgsql-11/bin/postgresql-11-setup initdb Start PostgreSQL #systemctl enable postgresql-11.service #systemctl start postgresql-11.service Verify su - postgres -c "psql" psql (11.0) Type "help" for help. postgres=# Create a password for user postgres for security purpose.  \password postgres Enable remote Acess to PostgreSQL Edit the file /var/lib/pgsql/11/data/postgresql.conf and set Listen address to your server IP address or “*” for all interfaces. listen_addresses = '192.168.18.9' Also set PostgreSQL to accept remote connections #vim /var/lib/pgsql/11/data/pg_hba.conf # Accept from anywhere host all all 0.0.0.0/0 md5 # Accept from trusted subnet host all al...

Tips troubleshooting network/systems administrator

Tips troubleshooting network/systems administrator: Sudah begitu banyak tutorial di internet, oleh karena itu di post ini saya berusaha untuk menceritakan pengalaman saya saja. Okey misalnya ketika services failed bisa karena ada salah konfigurasi, terkena  permission, terfilter oleh firewall, resources full, high traffic, disk/file corrupt, dll. 1. Memahami konsep, work flow project yang akan diselesaikan. 2. Teliti script, pastikan tidak ada yang typo. 3. Urutan step by step konfigurasi, pastikan sesuai dokumentasi. 4. Menjalankan program pada mode debug dan lihat log error, windows di event viewer, linux di /var/log/ 5. Copy error, pastikan copy error yang sesuai untuk di googling. 6. Cek versi os, software yang sedang dikonfigurasi, pastikan compatible, script konfigurasi sesuai dengan dokumentasi resmi software yang sedang dikonfigurasi. 7. Kesabaran, ketekunan, kesungguhan untuk browsing dan mencoba dari berbagai website, mencoba untuk memahami tutorial dalam ...

Basic NMAP

NMAP memiliki banyak options, berikut adalah contoh dasar penggunaan nmap: sudo  nmap -sS -O 127.0.0.1 -sS TCP SYN scan -O Enable Operating System detection -sU UDP ports scan -sS TCP SYN scan -p 20-25 Scan on ports 20 to 25 -F Fast (limited port) scan -Pn Treat all hosts as online -- skip host discovery TCP SYN and UDP scan for all ports nmap -sS -sU -p 1-65535 192.168.0.0/24 https://nmap.org/book/man-briefoptions.html