Monday, June 29, 2015

[DEBIAN] Installasi Samba

29 Juni 2015

Instalasi SAMBA pada server Debian mungkin possible juga diimplementasikan ke RPI (referensi link ada di dasar post)

1. sudo apt-get install samba
2. sudo nano /etc/samba/smb.conf

[name-folder]
path = /path/to/dir
browseable = yes
writeable = yes
guest ok = no
public = no
read only = no
security = user

3. sudo smbpasswd -a user
4. sudo service samba restart

catatan:
- pembuatan user untuk samba samakan dengan user yang sudah ada, jika belum ada buat user dengan adduser
- perhatikan owner & permission pada directory yang akan disamba
- install samba-common-bin untuk raspberry pi

Referensi:
-http://endrisuryanti.blogspot.com/2015/02/install-samba-di-linux-debian-server.html
-https://www.digitalocean.com/community/tutorials/how-to-add-delete-and-grant-sudo-privileges-to-users-on-a-debian-vps

Wednesday, June 24, 2015

[CheatSheet] PHP MySQL

22 Juni 2015

MYSQL

- Reset auto increment
ALTER TABLE tablename AUTO_INCREMENT = 1

- clear table
TRUNCATE TABLE tablename

- select table
SELECT * FROM table

- insert row
INSERT INTO table_name (column1, column2, column3,...)
VALUES (value1, value2, value3,...)

- insert multi row
INSERT INTO table_name (column1, column2, column3,...)
VALUES (value1, value2, value3,...),
       (value1, value2, value3,...),
       (value1, value2, value3,...);

PHP5

-date
date("Y-m-d");                         // 2015-10-01

-time
date("Y-m-d H:i:s");                   // 2015-10-01 17:03:18

-do while
$x = 1; 
do {
    echo "The number is: $x <br>";
    $x++;
}

while ($x <= 5);


-call db
$query = 'SELECT * FROM table';
$mysql = $conn->query($qno);
if ($mysql->num_rows > 0) {
    while($row = $result->fetch_assoc()) {
//interesting here
    }
}

Monday, June 22, 2015

[OpenWRT] Add on

22 Juni 2015

Beberapa add-on yang ku install pada openwrt

- enable sftp
opkg install openssh-sftp-server

- nano
opkg install nano

- wget
opkg install wget

Referensi
http://wiki.openwrt.org/doc/howto/sftp.server
http://www.cyberciti.biz/faq/wget-example-download-from-https-web-sites/

Sunday, June 21, 2015

[OpenWRT] Extroot OpenWRT

21 Juni 2015

Extroot OpenWrt Attitude Adjustment 12.09-rc1 - OpenWrtID / LuCI 0.11 Branch (0.11+svn9599) di TP-LINK MR3420 v2

1. Format Flashdisk
-partisi 1 = primary dengan format ext4 (size besar)
-partisi 2 = primary dengan format linux swap (size kecil)
2. Colok flashdisk ke router dan login via ssh
3. cek UUID flashdisk dengan format ext4 dengan command blkid
4. copy UUID
5. masuk web interface openwrt
6. system - mount point - mount point - edit
general setting
7. enable mount (ceklis)
8. mount point root (/)
9. use as root file system (ceklis)

advance
10. paste UUID flashdisk - save

11. kembali ke system - mount point - swap - edit
general setting
12. enable this swap (ceklis)
13. save and reboot

catatan:
- pada versi ini kmod-usb-storage kmod-fs-ext4 sudah terinstall

Referensi:
-https://www.youtube.com/watch?v=at_UZHkOYI8
-http://www.kaskus.co.id/show_post/000000000000000493416937/3/optional

Sunday, June 7, 2015

[RPI] Instalasi OPENVPN pada Raspberry Pi

7 Juni 2015



Instalasi OPENVPN pada Raspberry Pi, mengikuti tutorial dari mas ari-f berikut dapat di implementasikan ke rpi (link ada di dasar post)

1. Test RPI dengan command cat /dev/net/tun
jikalau muncul cat: /dev/net/tun: File descriptor in bad state artinya dapat melanjutkan instalasi openvpn.
2. sudo -s masuk sebagai root3. apt-get update && upgrade -y update RPI
4. cp -a /usr/share/doc/openvpn/examples/easy-rsa /etc/openvpn copy sample script ke /etc/openvpn
5. cd /etc/openvpn/easy-rsa/2.0 change dir /etc/openvpn/easy-rsa/2.0
6. source ./vars
7. ./clean-all
8. ./build-ca buat cert (dikosongkan saja enter enter)
9. ./build-dh buat diffie hellman parameter
10. ./build-key-server server01 generate certificate server (dikosongkan tak mengapa diakhir pertanyaan jawab dengan: yes)
11. openvpn --genkey --secret keys/ta.key udp flood protection
12. cd /etc/openvpn change dir /etc/openvpn
13. nano server.conf buat file server.conf
port 1194
proto udp
dev tun
ca keys/ca.crt
cert keys/server01.crt
key keys/server01.key
dh keys/dh1024.pem
plugin /usr/lib/openvpn/openvpn-auth-pam.so login
client-cert-not-required
username-as-common-name
server 10.8.0.0 255.255.255.0
ifconfig-pool-persist ipp.txt
push "redirect-gateway def1"
push "dhcp-option DNS 4.2.2.1"
push "dhcp-option DNS 4.2.2.2"
keepalive 5 30
comp-lzo
persist-key
persist-tun
status server-tcp.log
verb 3
14. nano server-tcp.conf buat file server-tcp.conf
port 465
proto tcp
dev tun
ca keys/ca.crt
cert keys/server01.crt
key keys/server01.key
dh keys/dh1024.pem
plugin /usr/lib/openvpn/openvpn-auth-pam.so login
client-cert-not-required
username-as-common-name
server 10.9.0.0 255.255.255.0
ifconfig-pool-persist ipp.txt
push "redirect-gateway def1"
push "dhcp-option DNS 4.2.2.1"
push "dhcp-option DNS 8.8.8.8"
keepalive 5 30
comp-lzo
persist-key
persist-tun
status server-tcp.log
verb 3
15. mkdir /etc/openvpn/keys buat folder untuk keys
16. cp /etc/openvpn/easy-rsa/2.0/keys/{ca.crt,server01.crt,server01.key,dh1024.pem,ta.key} /etc/openvpn/keys/ copy ca.crt,server01.crt,server01.key,dh1024.pem,ta.key ke keys folder
17. nano /etc/default/openvpn edit config openvpn dan uncoment AUTOSTART=ALL
18. /etc/init.d/openvpn restart restart openvpn
19. lsof -i |grep openvpn cek parameter (harus ada TCP dan UDP yang UP)
20. nano /etc/sysctl.d/forwarding.conf buat file untuk konfigurasi forwarding
net.ipv4.ip_forward=1
21. sysctl -p /etc/sysctl.d/forwarding.conf
22. iptables -t nat -I POSTROUTING -s 10.8.0.0/24 -o eth0 -j MASQUERADE setting iptables UDP
23. iptables -t nat -I POSTROUTING -s 10.9.0.0/24 -o eth0 -j MASQUERADE setting iptables TCP
24. mkdir clientconfig buat folder clientconfig dalam folder /etc/openvpn
25. cp /etc/openvpn/easy-rsa/2.0/keys/{ca.crt,ta.key} clientconfig/ copy ca.crt ta.key ke folder client config
26. cd clientconfig change directory client config
27. nano PI-UDP.ovpn buat konfigurasi client UDP
client
dev tun
proto udp
remote (IP RASPI) 1194
resolv-retry infinite
route-method exe
resolv-retry infinite
nobind
persist-key
persist-tun
ca ca.crt
auth-user-pass
comp-lzo
verb 3
28. nano PI-TCP.ovpn buat konfigurasi client TCP
client
dev tun
proto tcp
remote (IP RASPI) 465
resolv-retry infinite
route-method exe
resolv-retry infinite
nobind
persist-key
persist-tun
ca ca.crt
auth-user-pass
comp-lzo
verb 3
29. login ssh sebagai root dan copy ca.crt PI-UDP.ovpn PI-TCP.ovpn 
jika belum ada password untuk root: sudo passwd root dan ketikkan passwordnya
30. copy ke config client dan jalankan.

Referensi:
-http://www.ari-f.com/mumet-ndase/ok-baiklah-nih-tutorial-instal-openvpn-di-vps-debian
-https://www.raspberrypi.org/forums/viewtopic.php?p=67232

[CONSOLE] Looping Script

7 Juni 2015

Membuat program looping

> Windows bat

> Linux sh
$ cat every-5-seconds.sh
#!/bin/bash
while true
do
   /home/ramesh/backup.sh
   sleep 5
done
Referensi:
- http://www.thegeekstuff.com/2011/07/cron-every-5-minutes/
- http://stackoverflow.com/questions/166044/sleeping-in-a-batch-file
- http://ss64.com/nt/for.html