-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnon-osNotes
More file actions
90 lines (74 loc) · 3.74 KB
/
non-osNotes
File metadata and controls
90 lines (74 loc) · 3.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#!/bin/bash NOT A REAL SHELL SCRIPT!
# This is a cut'n'paste scriptlet
# be sure to read & understand what you're cutting & pasting!
#
# ISO date stamp
`date +%Y%m%d-%H%M`
################################################################################
# Edit remotefile on remoteserver (relative to login user homedir)
# <remoteserver> can be in user@hostname style
vim rsync://<remoteserver>/<remotefile>
# User-level mount of remotedirectory on remoteserver (generally temporary)
sshfs <remoteserver>:<path/to/remotedirectory> <mountpoint>
# Unmount the above:
fusermount -u <mountpoint>
# If rsync/scp not available, use tar and ssh with pipes
# copy to remoteserver
tar -cpf - <directory/filelist> | ssh <remoteserver> "cd <targetpath> && tar -xvpf -"
# (some versions of tar have a -C option)
tar -cpf - <directory/filelist> | ssh <remoteserver> tar -C <targetpath> -xpf -
# copy from remoteserver to current directory
ssh <remoteserver> 'tar czf <directory/filelist> -' | tar xzf -
#
################################################################################
# some ways to get list of make targets
make --print-data-base --dry-run
make -qp | awk -F':' '/^[a-zA-Z0-9][^$#\/\t=]*:([^=]|$)/ {split($1,A,/ /);for(i in A)print A[i]}'
make -pn | sed -rn '/^[^# \t\.%].*:[^=]?/p'
################################################################################
# crudini - script changes to ini-style config files
# Can be used to get values from non-ini-sytle files, just use DEFAULT section:
crudini --get <filename> DEFAULT <value>
# Can be used to set values, but must remember to remove section head after:
sed -i "s/\[DEFAULT\]//g" <filename>
################################################################################
#SSL stuff
# Create a self-signed OpenSSL Cert:
openssl genrsa -out bogus.key 1024
openssl req -new -key bogus.key -out bogus.csr
openssl x509 -req -days 365 -in bogus.csr -signkey bogus.key -out bogus.crt
# -- or -- #
openssl req -x509 -newkey rs:1024 -keyout my.key -out my.crt -days 2365 -nodes
# Read a sefl-signed cert:
openssl x509 -in bogus.pem -inform pem -noout -text
# get fingerprint of a public key file
ssh-keygen -lf <filename>
# get server cert thumbprint
echo ""|openssl s_client -connect <hostname>:443 2> /dev/null 1> /tmp/cert
openssl x509 -in /tmp/cert -fingerprint -sha1 -noout
# get key fingerprint
gpg --with-fingerprint keyname
################################################################################
## RegEx to match common RPM name/version strings:
^(\w+-?\w+\+*)-(\d+)\.?(\d+\w*)-?\.?(\d+\w*)(.*)
# This may be a bit better, untested:
^(\w+(-?\w+)*\+*)-(\d+)\.?(\d+\w*)-?\.?(\d+\w*)(.*)
################################################################################
## Wireshark stuff
# capture interface (eth0) for duration (10 seconds) and report info on port (80)
tshark -f 'tcp port 80 and tcp[tcpflags] & (tcp-syn) !=0 and tcp[tcpflags] & (tcp-ack) = 0' -n -q -z io,stat,1 -i eth0 -a "duration:10"
################################################################################
## sysdig stuff (most this needs to be done as root)
# Dump system activity to file, so that sysdig can be used to process it later.
sysdig -w trace.scap
# View the top network connections for a single container.
sysdig -pc -c topconns container.name=wordpress1
# See the files where apache spends the most time doing I/O.
sysdig -c topfiles_time proc.name=httpd
# Show all the interactive commands executed inside a given container.
sysdig -pc -c spy_users container.name=wordpress1
# Show every time a file is opened under /etc.
sysdig evt.type=open and fd.name contains /etc
# Find a *lot* more here: http://www.sysdig.org/wiki/sysdig-examples/
################################################################################
##