-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsecurity.sh
101 lines (72 loc) · 4.23 KB
/
security.sh
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
#!/usr/bin/env bash
# Inspired by:
# - https://github.com/drduh/macOS-Security-and-Privacy-Guide
# - https://github.com/mathiasbynens/dotfiles
# - https://github.com/MikeMcQuaid/strap
# Ask for the administrator password upfront
sudo -v
# Keep-alive: update existing `sudo` time stamp until the script has finished
while true; do sudo -n true; sleep 60; kill -0 $$ || exit; done 2>/dev/null &
# Prevent sleeping until the script has finished
caffeinate -s -w $$ &
echo "Hardening macOS..."
###############################################################################
# Hostname #
###############################################################################
HOSTNAME="kikazaru"
# Set computer name (as done via System Preferences → Sharing)
sudo scutil --set ComputerName $HOSTNAME
sudo scutil --set HostName $HOSTNAME
sudo scutil --set LocalHostName $HOSTNAME
sudo defaults write /Library/Preferences/SystemConfiguration/com.apple.smb.server NetBIOSName -string $HOSTNAME
###############################################################################
# Disk Encryption #
###############################################################################
# Enable FileVault
sudo fdesetup enable
###############################################################################
# Application Firewall #
###############################################################################
# Enable Application Firewall
sudo /usr/libexec/ApplicationFirewall/socketfilterfw --setglobalstate on
# Turn on logging mode
sudo /usr/libexec/ApplicationFirewall/socketfilterfw --setloggingmode on
# Enable stealth mode
sudo /usr/libexec/ApplicationFirewall/socketfilterfw --setstealthmode on
# Restart the Application Firewall process
sudo pkill -HUP socketfilterfw
###############################################################################
# DNS #
###############################################################################
# TODO: Set up `dnscrypt-proxy`
###############################################################################
# Spotlight Suggestions #
###############################################################################
# TODO: Disable Spotlight Suggestions in the Spotlight preferences
###############################################################################
# Screensaver #
###############################################################################
# Require password immediately after sleep or screen saver begins
defaults write com.apple.screensaver askForPassword -int 1
defaults write com.apple.screensaver askForPasswordDelay -int 0
###############################################################################
# Software Updates #
###############################################################################
# Enable the automatic update check
defaults write com.apple.SoftwareUpdate AutomaticCheckEnabled -bool true
# Check for software updates daily, not just once per week
defaults write com.apple.SoftwareUpdate ScheduleFrequency -int 1
# Download newly available updates in background
defaults write com.apple.SoftwareUpdate AutomaticDownload -int 1
# Install System data files & security updates
defaults write com.apple.SoftwareUpdate CriticalUpdateInstall -int 1
# Turn on app auto-update
defaults write com.apple.commerce AutoUpdate -bool true
###############################################################################
# Transmission.app #
###############################################################################
# IP block list.
# Source: https://giuliomac.wordpress.com/2014/02/19/best-blocklist-for-transmission/
defaults write org.m0k.transmission BlocklistNew -bool true
defaults write org.m0k.transmission BlocklistURL -string "http://john.bitsurge.net/public/biglist.p2p.gz"
defaults write org.m0k.transmission BlocklistAutoUpdate -bool true