因为有不同的macos版本,可能有些技巧适用于低版本,如果刚好某个技巧需要,你可以尝试执行下。
1
|
sudo spctl --master-disable
|
终端打开后执行上面的命令回车,系统会要求输入电脑的开机密码,输入密码(输入时密码不会显示出来)后回车。
ssh 22/udp # SSH Remote Login Protocol
ssh 22/tcp # SSH Remote Login Protocol
改成
ssh 22022/udp # SSH Remote Login Protocol
ssh 22022022/tcp # SSH Remote Login Protocol
1
|
$ sudo launchctl unload /System/Library/LaunchDaemons/ssh.plist
|
1
|
$ sudo launchctl load -w /System/Library/LaunchDaemons/ssh.plist
|
1
2
3
4
5
6
7
8
|
start_time=`date "+%Y-%m-%d %H:%M:%S"`
end_time=`date "+%Y-%m-%d %H:%M:%S"`
unix_time_start=`date -j -f "%Y-%m-%d %H:%M:%S" "$start_time" +%s`
unix_time_end=`date -j -f "%Y-%m-%d %H:%M:%S" "$end_time" +%s`
duration=`expr $unix_time_end - $unix_time_start`
echo "本次运行时间: $duration 秒"
|
1
|
git config --global credential.helper osxkeychain
|
1
|
launchctl print-disabled system
|
比如
1
|
"com.xk72.charles.ProxyHelper" => true
|
1
|
sudo launchctl enable system/com.xk72.charles.ProxyHelper
|
MacOS 不支持无密钥方式连接L2TP协议的VPN,需要在vpn的配置文件 /etc/ppp/options
中加入以下配置参数;
1
2
|
plugin L2TP.ppp
l2tpnoipsec
|
VPN 拨上之后,Mac 默认需要手动添加路由配置,才可以访问VPN Server侧内网的所有IP网络。
VPN拨上之后要让它自动添加路由条目,需要修改以下配置文件 /etc/ppp/ip-up
来实现;
1
2
3
4
5
6
7
|
$ cat /etc/ppp/ip-up
#!/bin/sh
filename="/tmp/vpn_route.log"
/sbin/route -n delete -net 172.0.0.0 -netmask 255.0.0.0 10.130.130.1 >>$filename 2>&1
/sbin/route -n add -net 172.0.0.0 -netmask 255.0.0.0 10.130.130.1 >>$filename 2>&1
|
修改配置文件的权限
1
|
chmod 755 /etc/ppp/ip-up
|
1
2
3
4
5
6
|
$ networksetup -listallnetworkservices
An asterisk (*) denotes that a network service is disabled.
Ethernet
802.11ac NIC
802.11ac NIC 2
Wi-Fi
|
可以看到有线网卡是Ethernet
1
2
3
|
$ networksetup -getautoproxyurl "Ethernet"
URL: http://127.0.0.1:11085/proxy.js
Enabled: Yes
|
1
|
$ networksetup -setautoproxyurl "Ethernet" "http://127.0.0.1:11085/proxy.js"
|
1
|
$ networksetup -setautoproxystate Ethernet off
|
1
|
$ networksetup -setsecurewebproxy "Ethernet" 192.168.31.120 8001
|
1
2
3
4
5
|
$ networksetup -getsecurewebproxy "Ethernet"
Enabled: Yes
Server: 192.168.31.120
Port: 8001
Authenticated Proxy Enabled: 0
|
1
|
$ networksetup -setsecurewebproxystate "Ethernet" off
|
1
|
$ networksetup -setwebproxy "Ethernet" 192.168.31.120 8001
|
1
2
3
4
5
|
$ networksetup -getwebproxy "Ethernet"
Enabled: Yes
Server: 192.168.31.120
Port: 8001
Authenticated Proxy Enabled: 0
|
1
|
$ networksetup -setwebproxystate "Ethernet" off
|
1
2
3
4
5
6
7
8
9
10
11
12
13
|
先查看 Wi-Fi 的 Device 名称:
networksetup -listnetworkserviceorder
一般是 en0,或是 en1 等
查询 WiFi 的开关状态
networksetup -getairportpower en0
关闭 Wi-Fi 的命令
networksetup -setairportpower en0 off
打开 Wi-Fi
networksetup -setairportpower en0 on
|
1
|
sudo /System/Library/CoreServices/RemoteManagement/ARDAgent.app/Contents/Resources/kickstart -activate -configure -access -on -clientopts -setvnclegacy -vnclegacy yes -clientopts -setvncpw -vncpw pnzwj -restart -agent -privs -all
|
1
|
sudo /System/Library/CoreServices/RemoteManagement/ARDAgent.app/Contents/Resources/kickstart -deactivate -configure -access -off
|
欢迎关注我的公众号testerzhang,原创技术文章第一时间推送。