Category Archives: Tips & Trik

Compress size file PDF

Menggunakan GhostScript command di ubuntu terminal untuk menjalankan kompres file pdf nya.

gs -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/screen -sOutputFile=output.pdf input.pdf

Berikut keterangan command untuk melakukan kompress file nya :

/screen – Lowest quality, lowest size
/ebook – Moderate quality
/printer – Good quality
/prepress – Best quality, highest size

Cheers – Andito Yugo Wicaksono

 

 

 

 

Advertisements

Cara untuk mengetahui Proses Listening Port – Port tertentu di system

Netstat

[1] Menggunakan netstat, install packet net-tools

apt install net-tools

[2] Melihat port – port yang aktif digunakan

# netstat -tulpn
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name 
tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 2652/mysqld 
tcp 0 0 0.0.0.0:21 0.0.0.0:* LISTEN 1308/vsftpd 
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 8587/sshd 
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 2571/master 
tcp6 0 0 :::80 :::* LISTEN 1301/httpd 
tcp6 0 0 :::22 :::* LISTEN 8587/sshd 
tcp6 0 0 ::1:25 :::* LISTEN 2571/master 
tcp6 0 0 :::443 :::* LISTEN 1301/httpd 

# netstat -tulpn | grep 80
tcp6 0 0 :::80 :::* LISTEN 1301/httpd

[3] Melihat semua Listing ports TCP dan UDP

# netstat -a | more
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State 
tcp 0 0 0.0.0.0:mysql 0.0.0.0:* LISTEN 
tcp 0 0 0.0.0.0:ftp 0.0.0.0:* LISTEN 
tcp 0 0 0.0.0.0:ssh 0.0.0.0:* LISTEN 
tcp 0 0 localhost:smtp 0.0.0.0:* LISTEN 
tcp 0 0 web.zotma:ssh 10.10.19.12:60726 ESTABLISHED
tcp6 0 0 [::]:http [::]:* LISTEN 
tcp6 0 0 [::]:ssh [::]:* LISTEN 
tcp6 0 0 localhost:smtp [::]:* LISTEN 
tcp6 0 0 [::]:https [::]:* LISTEN 
tcp6 0 0 web.zotma:https 10.10.19.12:58568 ESTABLISHED
tcp6 0 0 web.zotma:https 10.10.7.21:16723 TIME_WAIT 
tcp6 0 0 web.zotma:https 10.10.19.12:58554 TIME_WAIT 
tcp6 0 0 web.zotma:https 10.10.7.21:16710 TIME_WAIT 
tcp6 0 0 web.zotma:https 10.10.19.12:58564 FIN_WAIT2 
raw6 0 0 [::]:ipv6-icmp [::]:* 7 
Active UNIX domain sockets (servers and established)
Proto RefCnt Flags Type State I-Node Path
unix 2 [ ACC ] STREAM LISTENING 19054 public/pickup
unix 2 [ ACC ] STREAM LISTENING 19058 public/cleanup
unix 2 [ ACC ] STREAM LISTENING 10002 /run/lvm/lvmetad.sock
et
unix 2 [ ACC ] STREAM LISTENING 19068 private/rewrite
unix 2 [ ACC ] STREAM LISTENING 19071 private/bounce

[4] Show TCP Ports connections

# netstat -at
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State 
tcp 0 0 0.0.0.0:mysql 0.0.0.0:* LISTEN 
tcp 0 0 0.0.0.0:ftp 0.0.0.0:* LISTEN 
tcp 0 0 0.0.0.0:ssh 0.0.0.0:* LISTEN 
tcp 0 0 localhost:smtp 0.0.0.0:* LISTEN 
tcp 0 208 web.zotma:ssh 10.10.19.12:60726 ESTABLISHED
tcp6 0 0 [::]:http [::]:* LISTEN 
tcp6 0 0 [::]:ssh [::]:* LISTEN 
tcp6 0 0 localhost:smtp [::]:* LISTEN 
tcp6 0 0 [::]:https [::]:* LISTEN 
tcp6 0 0 web.zotma:https 10.10.19.12:58732 TIME_WAIT 
tcp6 0 0 web.zotma:https 10.10.19.12:58738 TIME_WAIT 
tcp6 0 0 web.zotma:https 10.10.7.21:16909 TIME_WAIT 
tcp6 0 0 web.zotma:https 10.10.7.21:16919 TIME_WAIT

[5] Show UDP Ports connections

netstat -au
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State 
udp 0 0 *:mdns *:* 
udp 0 0 *:42400 *:* 
udp 0 0 *:bootps *:* 
udp 0 0 *:bootps *:* 
udp 0 0 *:55521 *:* 
udp 0 0 localhost:35243 localhost:35243 ESTABLISHED
udp 0 0 *:ipp *:* 
udp6 0 0 [::]:44107 [::]:* 
udp6 0 0 [::]:mdns [::]:*

[6] Show all Listening Connections

netstat -l
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State 
tcp 0 0 0.0.0.0:mysql 0.0.0.0:* LISTEN 
tcp 0 0 0.0.0.0:ftp 0.0.0.0:* LISTEN 
tcp 0 0 0.0.0.0:ssh 0.0.0.0:* LISTEN 
tcp 0 0 localhost:smtp 0.0.0.0:* LISTEN 
tcp6 0 0 [::]:http [::]:* LISTEN 
tcp6 0 0 [::]:ssh [::]:* LISTEN 
tcp6 0 0 localhost:smtp [::]:* LISTEN 
tcp6 0 0 [::]:https [::]:* LISTEN 
raw6 0 0 [::]:ipv6-icmp [::]:* 7 
Active UNIX domain sockets (only servers)
Proto RefCnt Flags Type State I-Node Path
unix 2 [ ACC ] STREAM LISTENING 19054 public/pickup
unix 2 [ ACC ] STREAM LISTENING 19058 public/cleanup
unix 2 [ ACC ] STREAM LISTENING 10002 /run/lvm/lvmetad.socket
unix 2 [ ACC ] STREAM LISTENING 19068 private/rewrite

[7] Show all TCP Listening Ports

# netstat -lt
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State 
tcp 0 0 0.0.0.0:mysql 0.0.0.0:* LISTEN 
tcp 0 0 0.0.0.0:ftp 0.0.0.0:* LISTEN 
tcp 0 0 0.0.0.0:ssh 0.0.0.0:* LISTEN 
tcp 0 0 localhost:smtp 0.0.0.0:* LISTEN 
tcp6 0 0 [::]:http [::]:* LISTEN 
tcp6 0 0 [::]:ssh [::]:* LISTEN 
tcp6 0 0 localhost:smtp [::]:* LISTEN 
tcp6 0 0 [::]:https [::]:* LISTEN

[8] Show all UDP Listening Ports

netstat -lu
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State 
udp 0 0 *:mdns *:* 
udp 0 0 *:42400 *:* 
udp 0 0 userlocal:domain *:* 
udp 0 0 *:bootps *:* 
udp 0 0 *:bootps *:* 
udp 0 0 *:55521 *:* 
udp 0 0 *:ipp *:* 
udp6 0 0 [::]:44107 [::]:* 
udp6 0 0 [::]:mdns [::]:*

[9] Show Statistics Protocol TCP/UDP

TCP :

# netstat -st
IcmpMsg:
 InType3: 67
 InType8: 2
 OutType0: 2
 OutType3: 71
Tcp:
 106 active connections openings
 3826 passive connection openings
 0 failed connection attempts
 21 connection resets received
 1 connections established
 42378 segments received
 51180 segments send out
 598 segments retransmited
 0 bad segments received.
 55 resets sent
UdpLite:
TcpExt:
 19 invalid SYN cookies received
 3803 TCP sockets finished time wait in fast timer
 3804 delayed acks sent
 Quick ack mode was activated 12 times
 5767 packet headers predicted
 15270 acknowledgments not containing data payload received
 2899 predicted acknowledgments
 54 times recovered from packet loss by selective acknowledgements
 4 congestion windows recovered without slow start after partial ack
 TCPLostRetransmit: 40
 401 fast retransmits
 121 forward retransmits
 23 retransmits in slow start
 66 other TCP timeouts
 TCPLossProbes: 128
 TCPLossProbeRecovery: 5
 25 SACK retransmits failed
 12 DSACKs sent for old packets
 6 connections reset due to unexpected data
 3 connections reset due to early user close
 TCPSpuriousRTOs: 4
 TCPSackShiftFallback: 1028
 TCPDeferAcceptDrop: 3813
 TCPRcvCoalesce: 296
 TCPSpuriousRtxHostQueues: 1
 TCPAutoCorking: 2410
 TCPSynRetrans: 3
 TCPOrigDataSent: 33107
 TCPHystartTrainDetect: 31
 TCPHystartTrainCwnd: 572
 TCPHystartDelayDetect: 14
 TCPHystartDelayCwnd: 253
IpExt:
 InBcastPkts: 46375
 InOctets: 15471738
 OutOctets: 32197082
 InBcastOctets: 7371334
 InNoECTPkts: 107073

UDP :

# netstat -su
IcmpMsg:
 InType3: 67
 InType8: 2
 OutType0: 2
 OutType3: 71
Udp:
 0 packets received
 67 packets to unknown port received.
 0 packet receive errors
 261 packets sent
 0 receive buffer errors
 0 send buffer errors
UdpLite:
IpExt:
 InBcastPkts: 46378
 InOctets: 15477053
 OutOctets: 32206459
 InBcastOctets: 7371632
 InNoECTPkts: 107124

[10] Menampilkan nama service dengan PID

# netstat -tp
Active Internet connections (w/o servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name 
tcp 0 224 web.zotma:ssh 10.10.19.12:60726 ESTABLISHED 8757/sshd: root@pts 
tcp6 0 0 web.zotma:https 10.10.7.21:17455 TIME_WAIT - 
tcp6 0 0 web.zotma:https 10.10.19.12:58916 TIME_WAIT - 
tcp6 0 0 web.zotma:https 10.10.7.21:17456 ESTABLISHED -

[11] Melihat Network Interface Transactions

# netstat -i
Kernel Interface table
Iface MTU RX-OK RX-ERR RX-DRP RX-OVR TX-OK TX-ERR TX-DRP TX-OVR Flg
enp2s0 1500 200366 0 0 0 52389 0 0 0 BMRU
lo 65536 281 0 0 0 281 0 0 0 LRU

[12] Melihat Informasi IPv4 dan IPv6

# netstat -g
IPv6/IPv4 Group Memberships
Interface RefCnt Group
--------------- ------ ---------------------
lo 1 224.0.0.1
enp2s0 1 224.0.0.1
lo 1 ff02::1
lo 1 ff01::1
enp2s0 1 ff02::1:ff27:6bf9
enp2s0 1 ff02::1
enp2s0 1 ff01::1

[13] Finding Listening Programs

# netstat -ap | grep https
tcp6 0 0 [::]:https [::]:* LISTEN 1301/httpd 
tcp6 0 0 web.zotma:https 10.10.19.23:33088 TIME_WAIT - 
tcp6 0 0 web.zotma:https 10.10.19.25:18649 TIME_WAIT - 
tcp6 0 0 web.zotma:https 10.10.19.25:18639 TIME_WAIT - 
tcp6 0 0 web.zotma:https 10.10.19.23:33096 TIME_WAIT -

 

lsof

Install lsof :

$ sudo apt-get install lsof

Command – command lsof

$ lsof --help
lsof: illegal option character: -
lsof: -e not followed by a file system path: "lp"
lsof 4.89
 latest revision: ftp://lsof.itap.purdue.edu/pub/tools/unix/lsof/
 latest FAQ: ftp://lsof.itap.purdue.edu/pub/tools/unix/lsof/FAQ
 latest man page: ftp://lsof.itap.purdue.edu/pub/tools/unix/lsof/lsof_man
 usage: [-?abhKlnNoOPRtUvVX] [+|-c c] [+|-d s] [+D D] [+|-E] [+|-e s] [+|-f[gG]]
 [-F [f]] [-g [s]] [-i [i]] [+|-L [l]] [+m [m]] [+|-M] [-o [o]] [-p s]
 [+|-r [t]] [-s [p:s]] [-S [t]] [-T [t]] [-u s] [+|-w] [-x [fl]] [--] [names]
Defaults in parentheses; comma-separated set (s) items; dash-separated ranges.
 -?|-h list help -a AND selections (OR) -b avoid kernel blocks
 -c c cmd c ^c /c/[bix] +c w COMMAND width (9) +d s dir s files
 -d s select by FD set +D D dir D tree *SLOW?* +|-e s exempt s *RISKY*
 -i select IPv[46] files -K list tasKs (threads) -l list UID numbers
 -n no host names -N select NFS files -o list file offset
 -O no overhead *RISKY* -P no port names -R list paRent PID
 -s list file size -t terse listing -T disable TCP/TPI info
 -U select Unix socket -v list version info -V verbose search
 +|-w Warnings (+) -X skip TCP&UDP* files -Z Z context [Z]
 -- end option scan 
 -E display endpoint info +E display endpoint info and files
 +f|-f +filesystem or -file names +|-f[gG] flaGs 
 -F [f] select fields; -F? for help 
 +|-L [l] list (+) suppress (-) link counts < l (0 = all; default = 0)
 +m [m] use|create mount supplement
 +|-M portMap registration (-) -o o o 0t offset digits (8)
 -p s exclude(^)|select PIDs -S [t] t second stat timeout (15)
 -T qs TCP/TPI Q,St (s) info
 -g [s] exclude(^)|select and print process group IDs
 -i i select by IPv[46] address: [46][proto][@host|addr][:svc_list|port_list]
 +|-r [t[m<fmt>]] repeat every t seconds (15); + until no files, - forever.
 An optional suffix to t is m<fmt>; m must separate t from <fmt> and
 <fmt> is an strftime(3) format for the marker line.
 -s p:s exclude(^)|select protocol (p = TCP|UDP) states by name(s).
 -u s exclude(^)|select login|UID set s
 -x [fl] cross over +d|+D File systems or symbolic Links
 names select named files or files on named file systems
Anyone can list all files; /dev warnings disabled; kernel ID check disabled.

Contoh menggunakan command -i

$ lsof -i :5900
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
remmina 4281 space 19u IPv4 52692 0t0 TCP 10.10.1.93:33538->10.1.1.70:5900 (ESTABLISHED)

 

fuser

Install psmisc :

$ sudo apt-get install psmisc

$ fuser
No process specification given
Usage: fuser [-fMuvw] [-a|-s] [-4|-6] [-c|-m|-n SPACE] [-k [-i] [-SIGNAL]] NAME...
 fuser -l
 fuser -V
Show which processes use the named files, sockets, or filesystems.

-a,--all display unused files too
 -i,--interactive ask before killing (ignored without -k)
 -k,--kill kill processes accessing the named file
 -l,--list-signals list available signal names
 -m,--mount show all processes using the named filesystems or block device
 -M,--ismountpoint fulfill request only if NAME is a mount point
 -n,--namespace SPACE search in this name space (file, udp, or tcp)
 -s,--silent silent operation
 -SIGNAL send this signal instead of SIGKILL
 -u,--user display user IDs
 -v,--verbose verbose output
 -w,--writeonly kill only processes with write access
 -V,--version display version information
 -4,--ipv4 search IPv4 sockets only
 -6,--ipv6 search IPv6 sockets only
 - reset options

udp/tcp names: [local_port][,[rmt_host][,[rmt_port]]]

Cheers – Andito Yugo Wicaksono

 

 

 

Membuat Banner Messages SSH Login

[1] Buat file banner, contoh membuat banner di

# vi /etc/banner.net

=Jika anda memiliki akses silahkan login=

[2] Ubah sshd_config file dan enable banners

# vi /etc/ssh/sshd_config
Banner /etc/banner.net

[3] Restart sshd service

# systemctl restart sshd

[4] Coba login ke server yang sudah di setting banner nya

$ ssh 10.10.1.10 -l root
=Jika anda memiliki akses silahkan login=
root@10.10.1.10's password:

 

SSH Warning Message untuk Users setelah Login

[1] Tambahkan Warning Message di file

# vi /etc/motd
Pergunakan hak akses anda sejujur mungkin

[2] ssh ke server

root@10.10.1.10's password: 
Last login: Tue Aug 8 09:31:50 2017 from 10.10.1.10
Pergunakan hak akses anda sejujur mungkin

Cheers – Andito Yugo Wicaksono

 

 

Membuat local user account di Windows Server 2016

Hal pertama yang harus di lakukan adalah dengan membuka tampilan windows server, pilih Computer Management.

Masuk ke menu Local Users and Groups, klik kanan di bagian user local dan pilih New User

Menambahkan user baru dan password, setelah selesai pilih create

Untuk menambahkan group ke administrator langkah – langkahnya adaah sebagai berikut, klik kanan Administrator pilih properties -> Klik Add -> Pilih Advanced -> Pilih Find Now -> Mencari user yang akan ditambahkan




Ok, untuk group Administrator sudah bisa menggunakan user susan

Cheers…

 

Setting git menggunakan proxy

Tips dan trik cara setting git menggunakan proxy server.

Di bawah ini adalah cara untuk menambahkan git config global di linux

git config --global http.proxy http://username:password@proxydomain:port
git config --global https.proxy http://username:password@proxydomain:port


Unset Proxy jika sudah disetting

git config --global --unset http.proxy
git config --global --unset https.proxy

Error yang umumnya muncul

502: URL/IP is unreachable from your network.
407: Proxy authentication Denied.
80 : Proxy has not been set properly.