Skip to content

Instantly share code, notes, and snippets.

@erangaeb
erangaeb / connect_mongodb
Created March 31, 2016 15:47
Connect to mongodb
# command
mongo --port <port> --host <host ip>
# example
mongo --port 27017 --host 10.0.3.36
@erangaeb
erangaeb / local_port_forwarding_syntax
Last active April 1, 2016 17:21
SSH local port forwarding syntax
# command
ssh -L <local-host>:<local-port> <container-ip>:<container-port> <username>@<remote-host>
# -L : indicates, local portforwarding
# <local-host> : local machine ip, its optionl(default localhost)
# <local-port> : local port to listen
# <container-ip> : container/service ip
# <container-port> : container/service port
# <username> : username of remote host
# <remote-host> : remote host ip
@erangaeb
erangaeb / ssh_port_forward_docker
Last active April 4, 2016 11:08
SSH port forward to remote postgres container
# example
ssh -L localhost:8888:172.17.42.1:15534 [email protected]
# 8888 : local listening port
# 172.17.42.1 : container ip(docker host)
# 15534 : container serving port
# pagero : remote host username
# 10.4.1.41 : remote host ip
# localhost is potional
@erangaeb
erangaeb / ssh_config
Last active April 4, 2016 11:17
SSH port forwarding via ~/.ssh/config
Host cmb_test
HostName 10.4.1.41
User pagero
LocalForward 7777 172.17.42.1:8443
LocalForward 8888 172.17.42.1:15534
LocalForward 212121 172.17.42.1:212121
# In here define three port forwading rules
# ssh
@erangaeb
erangaeb / block_facebook
Created April 9, 2016 08:14
Block facebook
# add to /etc/hosts file
127.0.0.1 facebook.com
127.0.0.1 www.facebook.com
@erangaeb
erangaeb / flush_dscache
Created April 9, 2016 08:15
Flush dscache
# flush dscache to apply the /etc/hosts changes
sudo dscacheutil -flushcache
@erangaeb
erangaeb / create_jail_directory
Created April 10, 2016 06:45
Chroot jail directory
# jail directory
mkdir ~/Workspace/research/jail
# jail directory content
cd ~/Workspace/research/jail
mkdir usr
mkdir bin
mkdir etc
mkdir lib
mkdir lib64
@erangaeb
erangaeb / chroot_command
Created April 10, 2016 06:57
Chroot command
# structure
sudo chroot <directory> <command>
# directory - jailing directory
# command - execuring command in the jail directory
# example
sudo chroot jail /bin/bash
@erangaeb
erangaeb / copy_bash
Created April 10, 2016 07:08
Copy /bin/bash
# jair dir
cd ~/Workspace/research/jail
# copy bash
cp /bin/bash bin
@erangaeb
erangaeb / ldd
Created April 10, 2016 07:48
View libraries
# command
ldd <command>
# example
ldd /bin/bash