Skip to content

Instantly share code, notes, and snippets.

@imjamespond
Last active October 13, 2019 14:30
Show Gist options
  • Save imjamespond/ec52758aa22937327e65b9c3e4aede01 to your computer and use it in GitHub Desktop.
Save imjamespond/ec52758aa22937327e65b9c3e4aede01 to your computer and use it in GitHub Desktop.
ssh_tunnel.sh
sed_reg_replacement_on_mac.sh
netcat udp hole punching
for ((i=1; i<=$2; i ++))
do
curl.exe $1/${i}.jpg -o ${i}.jpg
echo $i
done
for ((i=1; i<=100; i ++))
do
echo $i
done
for i in {1..100}
do
echo $i
done
for i in `seq 1 100`
do
echo $i
done
locah host
nc -up 22222 jamespond.eicp.net 11111
remote host
nc -lu 11111 -v
send something from local...
remote host
netstat -plan
udp 0 0 104.194.77.241:11111 219.137.141.100:35247 ESTABLISHED 19946/nc
shutdown local nc
nc -lu 22222
remote host
nc -up 11111 219.137.141.100 35247
these commands above should run fast or the nat session will be expired soon
for f in ./*; do
if [ -f $f ]&&[ `echo $f | grep -c ".js" ` -gt 0 ]; then
echo `pwd`/$f
sed -E -i '' "s#\"/(management|service-center)/.*\"#GetAbsUrl(&)#" $f
sed -E -i '' "s#'/(management|service-center)/.*'#GetAbsUrl(&)#" $f
fi
done
##########
Page='./build/index.html'
CSS=`grep -oe '/html/static/css/main.*.css' $Page`
JS=`grep -oe '/html/static/js/main.*.js' $Page`
echo $CSS $JS
sed -E -i '' "s#/html/static/css/main\..*\.css#${CSS}#" ${FTL}/html-head.ftl
sed -E -i '' "s#/html/static/js/main\..*\.js#${JS}#" ${FTL}/html-foot.ftl
if [[ $(id -u) -ne 0 ]]; then
echo "Please run as root"
exit
fi
#echo "docker:1212" | chpasswd
#chmod 0600 ./qy1_rsa
LOCAL=${1:-'12300'}
REMOTE=${2:-'12300'}
while true
do
echo $(date)" ssh tunnel start..."
ssh -NT -o ExitOnForwardFailure=yes -o ServerAliveInterval=60 -o ServerAliveCountMax=100 \
-R *:${REMOTE}:localhost:${LOCAL} git@121.201.24.170 -i ./qy1_rsa
sleep 30
done
@imjamespond
Copy link
Author

imjamespond commented Nov 28, 2017

How to make ssh tunnel open to public?
GatewayPorts=clientspecified or GatewayPorts clientspecified
In order to use that, you probably need to add "GatewayPorts yes" to your server's /etc/ssh/sshd_config

@imjamespond
Copy link
Author

imjamespond commented May 9, 2018

In case you want a hard link ln to a directory...

mount -t bind /var/www /home/user/workspace/www
This is very dangerous because most tools and programs will not be aware of the binding. I once did something like in the above example and then proceeded to rm -rf /home/user. Luckily, there was nothing relevant in /var/www.

@imjamespond
Copy link
Author

find some file larger than

find . -type f -size +4096c
to find files bigger than 4096 bytes.

And :

find . -type f -size -4096c
to find files smaller than 4096 bytes.

Notice the + and - difference after the size switch.

The -size switch explained:

-size n[cwbkMG]

File uses n units of space. The following suffixes can be used:

`b'    for 512-byte blocks (this is the default if no suffix  is
                            used)

`c'    for bytes

`w'    for two-byte words

`k'    for Kilobytes       (units of 1024 bytes)

`M'    for Megabytes    (units of 1048576 bytes)

`G'    for Gigabytes (units of 1073741824 bytes)

The size does not count indirect blocks, but it does count
blocks in sparse files that are not actually allocated. Bear in
mind that the `%k' and `%b' format specifiers of -printf handle
sparse files differently. The `b' suffix always denotes
512-byte blocks and never 1 Kilobyte blocks, which is different
to the behaviour of -ls.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment