IT notes

sed append

To append a line using sed that works on macOS: sed -e '/^telegraf_enab.*/a\'$'\n''telegraf_user="root"' If need to do it in multiple files, you could use find:  find . -name "rc.conf" -exec sed -i '' -e '/^telegraf_enab.*/a\'$'\n''telegraf_user="root"' {} \;

Python quit unexpectedly macOS Catalina

When running something depending on OpenSSL you may get something like this on macOS 10.15.2: The output of the report: To fix: brew reinstall openssl Then: cd /usr/local/lib sudo ln -s /usr/local/opt/openssl/lib/libssl.dylib libssl.dylib sudo ln -s /usr/local/opt/openssl/lib/libcrypto.dylib libcrypto.dylib

macOs catalina & python

Reinstall openssl: brew reinstall openssl And then: export DYLD_LIBRARY_PATH=/usr/local/opt/openssl/lib:$DYLD_LIBRARY_PATH Or create the link manually: cd /usr/local/lib sudo ln -s /usr/local/opt/openssl/lib/libssl.dylib libssl.dylib sudo ln -s /usr/local/opt/openssl/lib/libcrypto.dylib libcrypto.dylib Reinstall python: brew reinstall python Upgrade pip packages: pip install -U --user $(pip freeze | awk -F'[=]' '{print $1}')

mojave Iso

Create 12 GB tmp disk: hdiutil create -o /tmp/Mojave.cdr -size 12000m -layout SPUD -fs HFS+J Attach the disk: hdiutil attach /tmp/Mojave.cdr.dmg -noverify -mountpoint /Volumes/install_build Extract the installer: sudo /Applications/Install\ macOS\ --volume /Volumes/install_build Create the iso mv /tmp/Mojave.cdr.dmg ~/Desktop/InstallSystem.dmg hdiutil detach /Volumes/Install\ macOS\ Mojave hdiutil convert ~/Desktop/InstallSystem.dmg -format UDTO -o ~/Desktop/Mojave.iso Rename Mojave.iso.cdr to Mojave.iso

Block SSH on MacOS

To block incoming ssh connections, edit the /etc/pf.conf and add the following line at the bottom: block in log quick proto tcp from any to any port 22 You can use vim or use something like this: sudo sh -c "echo 'block in log quick proto tcp from any to any port 22' >> /etc/pf.conf" Then reload the pfrules: sudo pfctl -Fa -f /etc/pf.conf For this to work the firewall must be enabled.

macOs sparseimage

To create an install disk using an spare disk: $ hdiutil create -size 6GB -fs JHFS+ -volname "macOS_installmedia" -type SPARSE ~/Desktop/macOS_installmedia Mount it (or double-click in Finder to mount): $ hdiutil mount ~/Desktop/macOS_installmedia.sparseimage Use the createinstallmedia: $ sudo /Applications/Install\ macOS\ High\ --volume /Volumes/macOS_installmedia --applicationpath /Applications/Install\ macOS\ High\

MTU 1453

If after upgrading macOS to 10.13.4 wifi stop working give a try to change the MTU:

Delete Guest

To delete macOS Guest user: sudo dscl . -delete /Users/Guest This will avoid showing the Guest user on the login screen

ansible ImportError: No module named boto3

When using ansible (macOS) to fix this problem update your library: pip install --upgrade --user boto3 notice the –user it will update, your local $HOME/Library/Python/2.7/lib/python/site-packages By using --upgrade it will recreate the site-packages. Or create PYTHONPATH system variable: export PYTHONPATH=/usr/local/lib/python2.7/site-packages paramiko In case you get this error: Unicode-objects must be encoded before hashing", "unreachable": true Try: pip install --upgrade --user paramiko==2.0.6 To upgrade,reinstall ansible just in case:

brew update formula

Example: brew bump-formula-pr --strict --url immortal it will need an API GIT token: export HOMEBREW_GITHUB_API_TOKEN=XXXXX To keep in sync forked repo: git fetch upstream git co upstream/master git push -f origin master