在Ubuntu 10.10中直接传递私钥密码给openvpn命令

我尝试了不同参数的方法

我有密码。
这里下面的密码是mypassword

1)

root$ echo mypassword || openvpn client.conf.ovpn 

结果显示:

 mypassword 

2)

 root$ openvpn client.warriors.conf.ovpn || echo mypassword 

结果显示:

 Thu Jun 28 00:00:00 2012 us=757575 NOTE: OpenVPN 2.1 requires '--script-security 2' or higher to call user-defined scripts or executables Enter Private Key Password: 

(仍然需要input密码manualy)

我不想手动input密码。 我怎样才能做到这一点?

3)DUDE

运行脚本后,它退出,如下所示:

 Fri Jun 29 11:56:59 2012 us=707916 cf_max = 0 Fri Jun 29 11:56:59 2012 us=707925 cf_per = 0 Fri Jun 29 11:56:59 2012 us=707934 max_clients = 1024 Fri Jun 29 11:56:59 2012 us=707944 max_routes_per_client = 256 Fri Jun 29 11:56:59 2012 us=707953 auth_user_pass_verify_script = '[UNDEF]' Fri Jun 29 11:56:59 2012 us=707963 auth_user_pass_verify_script_via_file = DISABLED Fri Jun 29 11:56:59 2012 us=707973 ssl_flags = 0 Fri Jun 29 11:56:59 2012 us=707982 port_share_host = '[UNDEF]' Fri Jun 29 11:56:59 2012 us=707992 port_share_port = 0 Fri Jun 29 11:56:59 2012 us=708001 client = ENABLED Fri Jun 29 11:56:59 2012 us=708010 pull = ENABLED Fri Jun 29 11:56:59 2012 us=708020 auth_user_pass_file = '[UNDEF]' Fri Jun 29 11:56:59 2012 us=708032 OpenVPN 2.1.0 i686-pc-linux-gnu [SSL] [LZO2] [EPOLL] [PKCS11] [MH] [PF_INET6] [eurephia] built on Jul 12 2010 Fri Jun 29 11:56:59 2012 us=708131 NOTE: OpenVPN 2.1 requires '--script-security 2' or higher to call user-defined scripts or executables Enter Private Key Password: Fri Jun 29 11:56:59 2012 us=726649 WARNING: this configuration may cache passwords in memory -- use the auth-nocache option to prevent this Fri Jun 29 11:56:59 2012 us=726805 WARNING: file 'client-team-20110222.key' is group or others accessible Fri Jun 29 11:56:59 2012 us=727136 /usr/bin/openssl-vulnkey -q -b 1024 -m <modulus omitted> Fri Jun 29 11:56:59 2012 us=875611 Control Channel MTU parms [ L:1543 D:140 EF:40 EB:0 ET:0 EL:0 ] Fri Jun 29 11:56:59 2012 us=876742 Data Channel MTU parms [ L:1543 D:1450 EF:43 EB:4 ET:0 EL:0 ] Fri Jun 29 11:56:59 2012 us=876777 Local Options String: 'V4,dev-type tun,link-mtu 1543,tun-mtu 1500,proto TCPv4_CLIENT,cipher BF-CBC,auth SHA1,keysize 128,key-method 2,tls-client' Fri Jun 29 11:56:59 2012 us=876788 Expected Remote Options String: 'V4,dev-type tun,link-mtu 1543,tun-mtu 1500,proto TCPv4_SERVER,cipher BF-CBC,auth SHA1,keysize 128,key-method 2,tls-server' Fri Jun 29 11:56:59 2012 us=876810 Local Options hash (VER=V4): 'd902a8f8' Fri Jun 29 11:56:59 2012 us=876825 Expected Remote Options hash (VER=V4): '7e078940' Fri Jun 29 11:56:59 2012 us=877124 NOTE: UID/GID downgrade will be delayed because of --client, --pull, or --up-delay Fri Jun 29 11:56:59 2012 us=877145 Attempting to establish TCP connection with [AF_INET]89.105.130.193:444 [nonblock] Fri Jun 29 11:57:00 2012 us=877280 TCP connection established with [AF_INET]89.105.130.193:444 Fri Jun 29 11:57:00 2012 us=877337 Socket Buffers: R=[87380->131072] S=[16384->131072] Fri Jun 29 11:57:00 2012 us=877353 TCPv4_CLIENT link local: [undef] Fri Jun 29 11:57:00 2012 us=877364 TCPv4_CLIENT link remote: [AF_INET]89.105.130.193:444 Fri Jun 29 11:57:00 2012 us=877568 TLS: Initial packet from [AF_INET]89.105.130.193:444, sid=c5d843bc e9f3e6ab Fri Jun 29 11:57:04 2012 us=105788 VERIFY OK: depth=1, /C=IE/ST=NA/L=DUB/O=ABC.OpenVPN/OU=server-terminus/CN=terminus/emailAddress=ops@abc.com Fri Jun 29 11:57:04 2012 us=106189 VERIFY OK: nsCertType=SERVER Fri Jun 29 11:57:04 2012 us=106202 VERIFY OK: depth=0, /C=IE/ST=NA/O=abc.OpenVPN/OU=server-terminus/CN=terminus/emailAddress=ops@abc.com root@bond$ 

这样退出是正常的。

Solutions Collecting From Web of "在Ubuntu 10.10中直接传递私钥密码给openvpn命令"

在我的openvpn.conf

 ... askpass /etc/openvpn/jdoe.pass <<< new line here ca /etc/openvpn/jdoe_ca.crt cert /etc/openvpn/jdoe.crt key /etc/openvpn/jdoe.key ... 

文件/etc/openvpn/jdoe.pass只包含密码。 你可以把这个文件改为600 。 这种方法拯救了我的生命… 😉

 Ubuntu 12.04.4 LTS OpenVPN 2.2.1 x86_64-linux-gnu [SSL] [LZO2] [EPOLL] [PKCS11] [eurephia] [MH] [PF_INET6] [IPv6 payload 20110424-2 (2.2RC2)] built on Mar 13 2014 

尝试一个shell脚本,如:

 #!/usr/bin/expect -f spawn openvpn client.warriors.conf.open match_max 100000 expect "*?assword:*" send -- "mypassword" send -- "\r" expect eof 

你需要chmod + x这个,你也可以把它设置为一个环境变量,所以你不必输入目录。

看起来他们得到这个脚本的工作: https : //unix.stackexchange.com/questions/9055/establish-openvpn-tunnel-in-bash-script

如何将其存储到一个文件并使用--askpass /your/file--askpass在OpenVPN版本2.0-beta20中添加了--askpass选项,Maverick的版本是2.1.0-3ubuntu1 。

我想你只是轻扫||| 运营商。

| 将上一个命令的标准输出插入下一个命令的标准输入。

|| 仅当第一个命令失败(退出代码!= 0)时才启动第二个命令。

这个命令应该工作。

 root$ echo mypassword | openvpn client.conf.ovpn