---
title: "[更新]ubuntu linux如何\"导入\"openvpn配置文件启动登陆"
author: "vfate_linux"
date: "2014-05-17T23:05:22Z"
tags: ["Ubuntu", "openvpn", "导入"]
categories: ["互联网"]
slug: "ubuntu-linux-openvpn"
draft: false
lastmod: "2014-05-21T11:42:30Z"
id: 2067738
url: "https://govfate.iteye.com/blog/2067738"
---

假如你是ubuntu14.04 的用户 你会发现open vpn的导入功能暂时无法使用,貌似bug... 写了个导入运行脚本,从终端启动openvpn \[code="shell"]sudo apt-get install openvpn \[/code] run-openvpn.sh "导入"启动 openvpn脚本代码如下 \[code="shell"]#!/bin/bash OVPN\_FILE="$1" get\_crt() { local file\_name="$1" local ca\_file="${file\_name}-ca.crt" start\_line=\`grep -n '' "$file\_name" |awk -F':' '{ print $1 }'\` end\_line=\`grep -n '' "$file\_name" |awk -F':' '{ print $1 }'\` end\_line=\`expr $end\_line - 1\` count=\`expr $end\_line - $start\_line\` head -$end\_line "$file\_name" |tail -$count &gt; "$ca\_file" echo "$ca\_file" } ca\_file=\`get\_crt "$OVPN\_FILE"\` sudo openvpn --client --config "$OVPN\_FILE" --ca "$ca\_file" \[/code] 比如你下载的openvpn配置文件名字是:xxx-xxx.ovpn \[code="shell"]run-openvpn.sh xxx-xxx.ovpn\[/code] 运行过程中提示输入用户名密码,有的不用用户名密码,最后看到如下提示表示vpn已经连接上了: \[quote]Sat May 17 22:19:23 2014 Initialization Sequence Completed \[/quote] 附件中的文件是供大家测试使用 \[code="shell"] #解压附件的7z文件 7z x -pqwert openvpn-test.7z \[/code] 参考:\[url]http://askubuntu.com/questions/450493/openvpn-cant-import-configurations-on-new-14-04-installation\[/url]