-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathstartSharing.sh
executable file
·64 lines (57 loc) · 1.92 KB
/
startSharing.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
#!/bin/bash
# Enable SSH - SMB - Remote Management in OSX
# SSH
echo $(tput setaf 1)"SSH:"$(tput sgr0)
if [ "$(sudo systemsetup -getremotelogin | grep Off)" ]; then
echo "Remote login via SSH is disabled"
echo "Enabling remote login via SSH"
sudo systemsetup -setremotelogin on
elif [ "$(sudo systemsetup -getremotelogin | grep On)" ]; then
echo "Remote login via SSH is enabled"
echo "Disabling remote login via SSH"
sudo systemsetup -setremotelogin off
else echo "Something went wrong. Try again."
fi
# SMB
echo $(tput setaf 1)"SMB:"$(tput sgr0)
if [ "$(sudo launchctl list | grep smbd)" ]; then
echo "File sharing via SMB is enabled"
echo "Disabling file sharing via SMB"
sudo launchctl unload -w /System/Library/LaunchDaemons/com.apple.smbd.plist
else \
echo "File sharing via SMB is disabled"
echo "Enabling file sharing via SMB"
sudo launchctl load -w /System/Library/LaunchDaemons/com.apple.smbd.plist
sudo defaults write /Library/Preferences/SystemConfiguration/com.apple.smb.server.plist EnabledServices -array disk
fi
# Remote Management
echo $(tput setaf 1)"Remote management:"$(tput sgr0)
ks="/System/Library/CoreServices/RemoteManagement/ARDAgent.app/Contents/Resources/kickstart"
if [ "$(sudo launchctl list | grep -i screensharing)" ]; then
echo "Screen sharing via Remote Management is enabled"
echo "Disabling screen sharing via Remote Management"
sudo ${ks} \
-deactivate \
-configure \
-access \
-off
else \
echo "Screen sharing via Remote Management is disabled"
echo "Enabling screen sharing via Remote Management"
sudo ${ks} \
-activate \
-configure \
-access \
-on \
-clientopts \
-setvnclegacy \
-vnclegacy yes \
-clientopts \
-setvncpw \
-vncpw master \
-restart \
-agent \
-privs \
-all
fi
exit