macOS安装使用OpenConnect客户端替代cisco连接公司内网环境
mac_os安装openconnect服务
brew install openconnect
使用OpenConnect客户端拨通VPN,打开终端执行以下命令:
sudo openconnect -u 【VPN用户名】 https://ocvpn.sysu.edu.cn
启停脚本
#!/bin/bash #vpn启动脚本 ## start(){ if [ $(ps -ef |grep openconnect |grep -v grep|wc -l) -eq 0 ] then openconnect kvpn.ksyun.com --protocol=anyconnect --user w_gaohongyu --authgroup=ksyun -b --pid-file=/Users/gaohongyu/scripts/data/openconnect/pid [ $? -eq 0 ] && echo "openconnect is starting" || echo "openconnect start is error" else echo "openconnect is running,please do not start it again" fi } stop(){ if [ $(ps -ef |grep openconnect |grep -v grep|wc -l) -ne 0 ] then kill $(cat /Users/gaohongyu/scripts/data/openconnect/pid) && rm -rf /Users/gaohongyu/scripts/data/openconnect/pid [ $? -eq 0 ] && echo "openconnect is stopped" || echo "openconnect stop is error" else echo "openconnect is not running" fi } restart(){ stop start } status(){ if [ $(ps -ef |grep openconnect |grep -v grep|wc -l) -eq 0 ] then echo "openconnect is not running" else echo "openconnect is running" fi } # ## case $1 in start) start ;; stop) stop ;; restart) restart ;; status) status ;; *) echo "usage:$0 (start|stop|restart|status)" exit 1 esac
写到环境变量开启快捷键
cat .zshrc function vpn-start { sudo /Users/gaohongyu/ghy/shell/vpn start } function vpn-stop { sudo /Users/gaohongyu/ghy/shell/vpn stop } function vpn-restart { sudo /Users/gaohongyu/ghy/shell/vpn restart } function vpn-status { sudo /Users/gaohongyu/ghy/shell/vpn status }
启动:vpn-start
停止:vpn-stop
重启:vpn-restart
状态:vpn-status
QQ:1061767621
Q群:215481318
本文作者:高宏宇
本文链接:https://www.cnblogs.com/gaohongyu/p/14885553.html
版权声明:本作品采用知识共享署名-非商业性使用-禁止演绎 2.5 中国大陆许可协议进行许可。
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步