Pass private key password to openvpn command directly in Ubuntu 10.10 [closed]

早过忘川 提交于 2019-11-30 01:58:24
smillien62

In my 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
...

The file /etc/openvpn/jdoe.pass just contains the password. You can chmod this file to 600. This method save my life... ;-)

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
Sturm

Try a shell script such as:

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

You'll need to chmod +x this, you can also set it as an environment variable so you don't have to type out the directory.

Looks like they got this script to work: https://unix.stackexchange.com/questions/9055/establish-openvpn-tunnel-in-bash-script

How about storing it into a file and using --askpass /your/file? --askpass option was added in OpenVPN version 2.0-beta20, Maverick has version 2.1.0-3ubuntu1.

I think you just swipe | and || operator.

| plug standard output o the previous command to standard input of the next command.

|| launch second command only if first command fail (exit code != 0).

this command should work.

root$ echo mypassword | openvpn client.conf.ovpn
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!