find out what process is binding the port 4000 with lsof
lsof -i tcp:4000
and use netstat
netstat -lnt -p tcp
| $ nproc | |
| 32 | |
| $ lscpu | |
| Architecture: x86_64 | |
| CPU op-mode(s): 32-bit, 64-bit | |
| Byte Order: Little Endian | |
| CPU(s): 32 | |
| On-line CPU(s) list: 0-31 |
find out what process is binding the port 4000 with lsof
lsof -i tcp:4000
and use netstat
netstat -lnt -p tcp
do not check host key
ssh -o StrictHostKeyChecking=no user@ssh-server
.ssh/config settings for all hosts with DSA
PubkeyAcceptedKeyTypes=+ssh-dss
KexAlgorithms +diffie-hellman-group1-sha1
https://www.mostlynetworks.com/2016/10/fixing-macos-sierraopenssh-7-x-compatibility/
| # jq can not write back to the same file | |
| for i in `find . -name '*.json'` | |
| do | |
| jq '.' $i > $i.tmp | |
| mv $i.tmp $i | |
| done | |
| # oneliner version | |
| # for i in `find . -name '*.json'`; do jq '.' $i > $i.tmp && mv $i.tmp $i; done |
| # only add when the json file does not have new line | |
| git ls-files | grep json | while read f; do tail -n1 $f | read -r _ || echo >> $f; done | |
| # https://unix.stackexchange.com/questions/31947/how-to-add-a-newline-to-the-end-of-a-file | |
| # https://unix.stackexchange.com/questions/192786/what-is-the-meaning-of-read-r |
Using sed to append something after search pattern.
sed -i '/PATTERN/a\APPENDED' <file>
For example, this will add "sample": "sample x", after "flows": .*, to test_inactive.json
sed -i '/"flows": .*,/a\ "sample": "sample x",' test.json
| """ | |
| For Python ≥ 3.2, os.makedirs has an optional third argument exist_ok that, when true, enables the mkdir -p functionality -- unless mode is provided and the existing directory has different permissions than the intended ones; in that case, OSError is raised as previously. | |
| """ | |
| import errno | |
| import os | |
| def mkdir_p(path): | |
| try: | |
| os.makedirs(path) |
Example config for mac only
Host bastion
Hostname ssh-bastion.example.com
IdentityFile ~/.ssh/bastion_ssh.key
User bastion-user
# internal server on private network
Host 172.18.* 192.168.*
ProxyJump bastion
Both include flags needs to go before exclude. The -z, --compress will compress the files during transfer and the -m, --prune-empty-dirs will delete empty folders in destination.
rsync -avmz --include="*/" --include="*.sh" --exclude="*" "$from" "$to"