Skip to content

Instantly share code, notes, and snippets.

@rdkls
rdkls / go.py
Created September 6, 2018 12:20
ncclient demo
#!/usr/bin/env python
import ncclient.manager
import lxml
host = 'ios-xe-mgmt.cisco.com'
ssh_port = 8181
netconf_port = 10000
username = 'root'
password = 'D_Vay!_10&'
#!/usr/bin/env python
# Connect to a host with specified public key
# Failure will raise paramiko.ssh_exception.BadHostKeyException w00p w00p!
import paramiko
import base64
host = 'localhost'
port = '8022'
keytype = 'ssh-rsa'
host_key_b64 = 'AAAAB3NzaC1yc2EAAAADAQABAAABAQDKwtRsDG4PpErhl0orhYZ6GLb/xPk81hUm7QWDMbAt3BKz1GrTnbZ0VZjmDE/joXVs6cNt9UvFvpVymwbx2IdqY9qN4DrWpZtzQ4l1asgcGGVbzX0wj2r6ZJbm9AhPW9WDZ4Ke/Hwbs/MxxKkEuQYRJekfnFTO1zRu1xyptwuLCS6P+Y79W+EiFLV8/9jZHjRlcpD+Fi4K0NSluDOrXw6Zn5XqXPSAYYkAOQnFGTfZuOGu5iyK1KVEGO7YS1WCAqnmyVF1RqJI1ehEUqjhqd8UYlD0Uq7KlPuA+EIzsDdEZ9vhMEbPBf0tgh9Lt+3UaTFNTGsdoDSdWuM13v+BR463'
@rdkls
rdkls / ssl_proxy.sh
Created August 31, 2018 08:26
ssl proxy to plain tcp
#!/usr/bin/fish
set FILENAME host
set SRC_PORT 4433
set DST_PORT 8052
set DST_HOST 127.0.0.1
openssl genrsa -out $FILENAME.key
openssl req -new -key $FILENAME.key -x509 -days 3653 -out $FILENAME.crt -subj "/C=AU/ST=Zuid Holland/L=Rotterdam/O=Sparkling Network/OU=IT Department/CN=ssl.localhost.org"
cat $FILENAME.key $FILENAME.crt >$FILENAME.pem
chmod 600 $FILENAME.key $FILENAME.pem
echo "Listening on $SRC_PORT ..."
export REGION=`curl -s http://169.254.169.254/latest/dynamic/instance-identity/document | jq -r .region`
and get an ssm parameter value:
export POSTGRES_USER=`aws ssm get-parameter --name=$SSM_PARAMETER_NAME_DB_USERNAME --region=$REGION --with-decryption | jq -r .Parameter.Value`
@rdkls
rdkls / gist:a22553d9f459610a6750cc60589f8301
Created July 20, 2018 06:48
user systemd service to start ssh-agent
in ~/.config/systemd/user/ssh-agent.service
[Unit]
Description=SSH key agent
[Service]
Type=forking
Environment=SSH_AUTH_SOCK=%t/ssh-agent.socket
ExecStart=/usr/bin/ssh-agent -a $SSH_AUTH_SOCK
@rdkls
rdkls / .vimrc
Created June 29, 2018 06:34 — forked from dragonken/.vimrc
YAML space indent for vim
syntax on
filetype plugin indent on
# Get the 2-space YAML as the default when hit carriage return after the colon
autocmd FileType yaml setlocal ts=2 sts=2 sw=2 expandtab
[2:53 PM] Nick Doyle: ~/.cisco/hostscan/log/cscan.log:
[2:53 PM] Nick Doyle: [Mon Jun 25 14:51:20.732 2018][cscan]Function: process_host_scans Thread Id: 0xB60F9B80 File: scan.c Line: 148 Level: info :: scanning environment...
[Mon Jun 25 14:51:20.732 2018][cscan]Function: process_inspector_scans Thread Id: 0xB60F9B80 File: scan.c Line: 207 Level: info :: scanning for security software...
[Mon Jun 25 14:51:20.857 2018][cscan]Function: scan_software_advanced Thread Id: 0xB60F9B80 File: scan_software.c Line: 696 Level: info :: performing advanced software scan.
[Mon Jun 25 14:51:20.857 2018][cscan]Function: scan_advanced_fw Thread Id: 0xB60F9B80 File: scan_software.c Line: 308 Level: info :: no firewall enforcement needed.
[Mon Jun 25 14:51:20.857 2018][cscan]Function: scan_advanced_av Thread Id: 0xB60F9B80 File: scan_software.c Line: 444 Level: info :: no antivirus enforcement needed.
[Mon Jun 25 14:51:20.857 2018][cscan]Function: scan_advanced_as Thread Id: 0xB60F9B80 File: scan_software.c Line: 582 Level: in
MY_DNS_HOSTNAME='vpn.foo.bar'
pritunl set app.acme_domain $MY_DNS_HOSTNAME
pritunl set app.acme_key "`openssl genrsa 4096`"
pritunl set app.acme_timestamp `python -c 'import time;print time.time()'`
pritunl set app.acme_renew 0
if [[ "`pgrep pritunl-web`" ]] ; then
echo 'restarting pritunl'
service pritunl restart
@rdkls
rdkls / kubernetes-nasa-lessons-knowledge.yml
Created March 9, 2018 01:53
kubernetes definition for neo4j deployment (docker containers) & service (external accessible) for NASA lessons learnt knowledge graph
apiVersion: v1
kind: ConfigMap
metadata:
name: nasa-neo4j-configmap
data:
neo4j.conf: |
dbms.directories.import=import
dbms.allow_format_migration=true
dbms.connectors.default_listen_address=0.0.0.0
dbms.connector.http.listen_address=:7474
@rdkls
rdkls / generate-schema.cql
Last active March 8, 2018 00:59
neo4j create schema based on existing nodes
// Generate an overview / schema of a graph database
// Creates a node for each node label found in the graph,
// relating these to each other for each type of relationship found in the graph
// (apoc call required to create rel with dynamic type)
MATCH (a)-[r]->(b)
WITH head(labels(a)) AS l, head(labels(b)) AS l2, type(r) AS rel_type, count(*) as num_links
merge (aMeta:Meta {label: l})
merge (bMeta:Meta {label: l2})
with aMeta, bMeta, rel_type, num_links
call apoc.create.relationship(aMeta, rel_type, {num_links: num_links}, bMeta) yield rel