Skip to content

Instantly share code, notes, and snippets.

View tuxfight3r's full-sized avatar
:octocat:
Working from home

Mohan Balasundaram tuxfight3r

:octocat:
Working from home
View GitHub Profile
@tuxfight3r
tuxfight3r / ssh-keygen
Last active August 8, 2023 08:27
ssh key / fingerprint tricks
#Read multiple keys from an authorized_keys file and print the finger print
[root@server01 .ssh]# while read line; do ssh-keygen -l -f /dev/stdin <<< $line; done < authorized_keys
2048 87:7a:4d:70:d2:10:a4:4b:b7:e1:2b:7c:77:92:25:04 /dev/stdin (RSA)
2048 7d:f0:89:94:00:09:bc:70:46:59:8d:9a:70:3b:ac:70 /dev/stdin (RSA)
2048 61:63:ee:0d:f6:d2:d8:d6:ae:37:0c:35:ae:da:51:6a /dev/stdin (RSA)
#read a key from authorized key file
[root@server01 .ssh]# ssh-keygen -l -f authorized_keys
2048 87:7a:4d:70:d2:10:a4:4b:b7:e1:2b:7c:77:92:25:04 authorized_keys (RSA)
@tuxfight3r
tuxfight3r / gist:169867c001684411814e5f8456f4a6ed
Created July 4, 2023 09:50
Java JMX inspection via visualvm or jconsole for a pod inside kubernetes
#to be able to view the java jmx internals of an application running in kubernetes as a pod
# set the below environment value in the pod definition
_JAVA_OPTIONS="-Dcom.sun.management.jmxremote
-Dcom.sun.management.jmxremote.authenticate=false
-Dcom.sun.management.jmxremote.ssl=false
-Dcom.sun.management.jmxremote.local.only=false
-Dcom.sun.management.jmxremote.port=5000
-Dcom.sun.management.jmxremote.rmi.port=5000
-Djava.rmi.server.hostname=127.0.0.1"
@tuxfight3r
tuxfight3r / curl.md
Created February 4, 2021 20:32 — forked from subfuzion/curl.md
curl POST examples

Common Options

-#, --progress-bar Make curl display a simple progress bar instead of the more informational standard meter.

-b, --cookie <name=data> Supply cookie with request. If no =, then specifies the cookie file to use (see -c).

-c, --cookie-jar <file name> File to save response cookies to.

@tuxfight3r
tuxfight3r / ruby_monk_primer.rb
Created July 27, 2016 11:27 — forked from brownmike/ruby_monk_primer.rb
Ruby Monk Primer My solutions to all problems in ascending order
# Problem Statement
# Create a class Calculator, which performs addition and subtraction of two numbers at a time.
class Calculator
def add(a, b)
a+b
end
def subtract(a, b)
a-b
end
@tuxfight3r
tuxfight3r / rsync-reposync.sh
Created July 13, 2015 10:45
Centos updates via rsync behind proxy
#!/bin/bash
Purpose: Sync centos7 repos via rsync behind proxy
Author: Mohan
#Makesure rsync port 873 is allowed outbound on the squid proxy
export RSYNC_PROXY=192.168.2.250:3128
#create directory structure
mkdir -p /opt/repo/yum/centos/{os,updates}
@tuxfight3r
tuxfight3r / inventory.py
Created March 10, 2016 13:10
ansible dynamic inventory python demo
#!/usr/bin/env python
'''
Example custom dynamic inventory script for Ansible, in Python.
'''
import os
import sys
import argparse
@tuxfight3r
tuxfight3r / bind_socket.py
Last active April 24, 2023 14:27
python tcp socket client / server examples
#!/usr/bin/python
import socket #for sockets
import sys #for exit
try:
#create an AF_INET, STREAM socket (TCP)
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
except socket.error, msg:
print 'Failed to create socket. Error code: ' + str(msg[0]) + ' , Error message : ' + msg[1]
@tuxfight3r
tuxfight3r / openshift_cli_tricks.MD
Last active March 30, 2023 18:02
openshift cli tricks - using go templates

openshift list all pods and thier specs (requests/limits)

oc get pod -o jsonpath='{range .items[*]}{"SPEC:  \n  LIMITS  : "}{.spec.containers[*].resources.limits}{"\n  REQUESTS: "}{.spec.containers[*].resources.requests}{"\n"}{end}'

openshift list all pods and thier specs with name (requests /limits)

oc get pod -o jsonpath='{range .items[*]}{"NAME:  "}{.metadata.name}{"\nSPEC:  \n  LIMITS  : "}{.spec.containers[*].resources.limits}{"\n  REQUESTS: "}{.spec.containers[*].resources.requests}{"\n\n"}{end}'
@tuxfight3r
tuxfight3r / socat-forward-tcp.sh
Created April 18, 2019 14:15 — forked from drmalex07/socat-forward-tcp4-to-tcp6.sh
Tunnel TCP traffic via socat. #socat
#!/bin/bash
PUBLIC_IP4_IFACE=eth2
LISTEN_IFACE=${PUBLIC_IP4_IFACE}
listen_address=$(ip -f inet addr show dev ${LISTEN_IFACE} | grep -Po 'inet \K[\d.]+')
listen_port=${1}
target_host=${2}
target_port=${3}
@tuxfight3r
tuxfight3r / inventory.sh
Created March 10, 2016 13:08
Ansible dynamic inventory bash demo
#!/bin/bash
if [ "$1" == "--list" ] ; then
cat<<EOF
{
"bash_hosts": {
"hosts": [
"10.220.21.24",
"10.220.21.27"
],