Anyconnect的VPN环境部署(2)-在Linux客户机上连接Anyconnect
由于之前已经在机房IDC安装了Anyconnect的VPN服务环境(参考:Anyconnect的VPN环境部署(1)-OpenConnect server(ocserv)服务安装)
今天介绍下在linux客户机上连接Anyconnect服务:
1)yum安装openconnect
[root@FangFull-backup ~]# wget http://dl.fedoraproject.org/pub/epel/epel-release-latest-6.noarch.rpm
[root@FangFull-backup ~]# rpm -ivh epel-release-latest-6.noarch.rpm
[root@FangFull-backup ~]# yum install -y openconnect
2)配置
下载openconnect.zip包(下载地址:https://pan.baidu.com/s/1c2ssqyc 提取密码:qihm)
将openconnect.zip解压到/usr/local目录下
[root@test-huanqiu src]# unzip openconnect.zip
[root@test-huanqiu src]# mv openconnect /usr/local/
[root@test-huanqiu src]# chmod -R 777 /usr/local/openconnect/
[root@test-huanqiu src]# cd /usr/local/openconnect/
[root@test-huanqiu openconnect]# ls
conf COPYING dist helpers install NEWS README scripts
[root@test-huanqiu openconnect]# cd conf/
[root@test-huanqiu conf]# ls
config example.conf
[root@test-huanqiu conf]# cat config
# VPN server to connect to. This is a mandatory option
VPN_SERVER="any.wangshiboholdings.com" //这个是Anyconnect的vpn地址
#server="116.137.17.11"
# vpnc script program to use. You can either use the one from vpnc, or use the
# ones from http://git.infradead.org/users/dwmw2/vpnc-scripts.git
SCRIPT_PROGRAM="/etc/vpnc/vpnc-script" //openconnect安装成功后,就会有这个脚本
# Username to use when connecting. Leave blank if you want to input it
# interactively everytime or if it isn't relevant
USERNAME="wangshibo" //这个是连接VPN的用户名
# If you do not want to type in your password everytime, this gives a file where
# your password is stored.
#PASSWORD_FILE="/etc/epfl-vpn.pass"
PASSWORD_FILE="/etc/vpnc/passwd" //这个是连接VPN的密码文件,里面是密码
# SHA1 SSL fingerprint of the your vpn server
SERVER_SHA1=""
# Path to SSL certificate of server (or CA having signed the server's
# certificate)
# SERVER_CERT="/etc/ssl/certs/QuoVadis_Root_CA.pem"
# Additional options that are directly passed to openconnect
ADDITIONAL_OPTS=""
3)创建密码文件/etc/vpnc/passwd,输入用户的密码
[root@test-huanqiu conf]# touch /etc/vpnc/passwd
[root@test-huanqiu conf]# echo "PASSWORD" > /etc/vpnc/passwd
[root@test-huanqiu conf]# cat /etc/vpnc/passwd
PASSWORD
4)创建anyconnect脚本日志文件,不然连接anyconnect会失败
[root@test-huanqiu conf]# touch /var/log/openconnect-script.log
5)创建启动脚本脚本
[root@test-huanqiu conf]# vim /bin/vpn_start
#!/bin/sh
/usr/local/openconnect/scripts/vpn-connect /usr/local/openconnect/conf/config
[root@test-huanqiu conf]# chmod 755 /bin/vpn_start
6)执行启动脚本,进行vpn连接
[root@test-huanqiu conf]# /bin/sh /bin/vpn_start
Openconnect successfully started. Use vpn-disconnect to stop.
[root@test-huanqiu conf]# ps -ef|grep vpn
root 894 1 0 09:26 pts/0 00:00:00 /usr/sbin/openconnect --background --no-cert-check --script=/etc/vpnc/vpnc-script --user=wangshibo --passwd-on-stdin any.wangshiboholdings.com
root 898 808 0 09:26 pts/0 00:00:00 grep --color=auto vpn
----------------------------------------------------------------------------------------------------------------------------------
上面使用脚本连接的Anyconnect,也可以用命令直接连接(即上面启动后查看的vpn状态中去掉--passwd-on-stdin部分后的命令)
[root@test-huanqiu conf]# /usr/sbin/openconnect --background --no-cert-check --script=/etc/vpnc/vpnc-script --user=wangshibo any.wamgshiboholdings.com
POST https://any.wangshiboholdings.com/
Attempting to connect to server 13.25.24.115:443
SSL negotiation with any.wangshiboholdings.com
Server certificate verify failed: unable to get local issuer certificate
Connected to HTTPS on any.wangshiboholdings.com
XML POST enabled
Please enter your username and password.
Password: //输入密码即可
POST https://any.wangshiboholdings.com/
Got CONNECT response: HTTP/1.1 200 OK
CSTP connected. DPD 30, Keepalive 20
RTNETLINK answers: File exists
/etc/vpnc/vpnc-script: line 228: /var/run/vpnc/resolv.conf-backup: No such file or directory
Script '/etc/vpnc/vpnc-script' returned error 1
Connected tun0 as 10.4.9.145, using SSL
Continuing in background; pid 6078
查看已经成功连接
[root@test-huanqiu conf]# ps -ef|grep vpn
root 894 1 0 09:26 pts/0 00:00:00 /usr/sbin/openconnect --background --no-cert-check --script=/etc/vpnc/vpnc-script --user=wangshibo any.wangshiboholdings.com
root 898 808 0 09:26 pts/0 00:00:00 grep --color=auto vpn
----------------------------------------------------------------------------------------------------------------------------------
7)创建监控脚本(直接执行这个脚本,也可以连接Anyconnect)
[root@test-huanqiu conf]# vim /root/vpn_monit.sh
#!/bin/bash
NUM=`ps -ef|grep openconnect|grep -v "grep"|wc -l`
if [ $NUM -eq 0 ];then
/bin/bash /bin/vpn_start >/dev/null 2>&1
else
echo "It is ok"
fi
8)结合crontab,实现定期检查
[root@test-huanqiu conf]# crontab -l
*/30 * * * * /bin/sh /bin/vpn_start >/dev/null 2>&2
* * * * * /bin/bash /root/vpn_monit.sh > /dev/null 2>&1
Anyconnect的VPN环境部署(2)-在Linux客户机上连接Anyconnect的更多相关文章
- Anyconnect的VPN环境部署(1)-OpenConnect server(ocserv)服务安装
打算在公司IDC机房部署一套VPN环境,经过考虑,最终决定采用Cisco下的开源技术AnyConnect.AnyConnect的优势有:1)长连接,待机不会断开:2)速度快,稳定性好:3)安全性好,全 ...
- Delphi 10.2 Linux 程序开发环境部署的基本步骤(网络连接方式要选择桥接或者是Host Only)
Delphi 10.2 Linux 程序开发环境部署的基本步骤 http://blog.qdac.cc/?p=4477 升級到 Delphi 10.2 Tokyo 笔记http://www.cnblo ...
- Centos下PPTP环境部署记录
PPTP(点到点隧道协议)是一种用于让远程用户拨号连接到本地的ISP,通过因特网安全远程访问公司资源的新型技术.它能将PPP(点到点协议)帧封装成IP数据包,以便能够在基于IP的互联网上进行传输.PP ...
- 一个CentOS7的开发环境部署,包括防火墙|VPN|多IP多网关|HTTP代理服务器设置等
http://www.lenggirl.com/code/centos7.html layout: post title: "一个CentOS7的开发环境部署,包括防火墙|VPN|HTTP代 ...
- Linux Debian 7部署LEMP(Linux+Nginx+MySQL+PHP)网站环境
我们在玩VPS搭建网站环境的时候,都经常看到所谓的LAMP.LNMP.LEMP,LAMP, 其中的A代表APECHE WEB驱动环境,LNMP中的N代表NGINX驱动环境,只不过海外的叫法NGINX ...
- Linux下FTP虚拟账号环境部署总结
vsftp的用户有三种类型:匿名用户.系统用户.虚拟用户.1)匿名登录:在登录FTP时使用默认的用户名,一般是ftp或anonymous.2)本地用户登录:使用系统用户登录,在/etc/passwd中 ...
- Linux环境:持续集成环境部署系列
之前的博客介绍了Linux环境下持续集成环境部署的一些内容,这篇博客将其整理一下,算做一个index,方便自己和大家查阅... 1.linux下安装JDK Jenkins是一个java开源的持续集成工 ...
- 环境部署(七):linux下Jenkins+Git+JDK持续集成
前面几篇博客介绍了linux下安装Jenkins.Git.JDK以及Git基础教程和Git关联github等内容,这篇博客,介绍下如何在linux服务器中利用它们构建持续集成环境... 一.准备工作 ...
- Linux下开源邮件系统Postfix+Extmail+Extman环境部署记录
一.基础知识梳理MUA (Mail User Agent) MUA 既是"邮件使用者代理人",因为除非你可以直接利用类似 telnet 之类的软件登入邮件主机来主动发出信件,否则您 ...
随机推荐
- Quartz2D复习(二) --- 手势解锁
这次支付宝手机客户端升级,把手势解锁那个功能去掉了,引起很多人的抱怨,觉得少了手势解锁的保护,个人信息容易泄漏了... 那么手势解锁功能是怎么是实现的呢,这里使用Quart2D来简单模拟一下, 先看下 ...
- Android-SQLite版本问题
1. 用户 重来没有使用过该软件 不存在数据库,我们 1). 自动调用 void onCreate(SQLiteDatabase db) 方法 创建数据库 2).创建 表 , 3).给表插入初始化数据 ...
- iOS Apple Pay
iOS 苹果支付 需要证书支持支付功能 targets 打开支付功能按钮 //ApplePay#import <PassKit/PassKit.h> ...
- Java Collection Framework概述
文章出自:听云博客 Collection概述 Java collection是java提供的工具包,包含了常用的数据结构:集合.链表.队列.栈.数组.映射等. Java集合主要可以划分为4个部分:Li ...
- 优化MySchool数据库(四)
关于“无法附件数据库”过程的遇到的问题: 1.数据文件本身,具有访问权限的限制 ---- 选中 数据库文件所在的文件夹---->右键菜单(属性)----> 安全 --->User用户 ...
- linux 学习随笔-group和user管理
1:/etc/passwd 打开该文件,可以看到每一行内容被分割成了7个字段比如:root:x:0:0:root:/root:/bin/bash 第一个字段表示用户名为root用户 第二个字段存放了该 ...
- [PL/SQL]oracle数据库的导出导入
一.PL/SQL Developer工具一般对oracle的导入导出有以下4中方式: 1.Oracle导出导入方式 这种方式导出导入为.dmp的文件格式,.dmp文件是二进制的,可以跨平台,还能包含权 ...
- Spring源码阅读系列总结
最近一段时间,粗略的查看了一下Spring源码,对Spring的两大核心和Spring的组件有了更深入的了解.同时在学习Spring源码时,得了解一些设计模式,不然阅读源码还是有一定难度的,所以一些重 ...
- Linux下Nagios的安装与配置[转]
一.Nagios简介 Nagios是一款开源的电脑系统和网络监视工具,能有效监控Windows.Linux和Unix的主机状态,交换机路由器等网络设置,打印机等.在系统或服务状态异常时发出邮件或短信报 ...
- python之装饰器
一.简单装饰器: #定义装饰器函数 def W1(main_func): def outer(): print("before") main_func() print(" ...