Pass the secret key password to the openvpn command directly in Ubuntu 10.10

I tried a method with a different parameter

I have a password.
Here is the password below - mypassword

one)

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

The result was displayed:

 mypassword 

2)

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

The result was displayed:

 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: 

(still need to enter the password manually)

I do not want to enter the password manually. How can I achieve this?

3) DUDE

After running the script, it will exit with the following:

 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 $ 

the output is thus normal.

+7
source share
4 answers

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 contains only the password. You can chmod this file 600 . This method will 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 
+36
source

Try a shell script, for example:

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

You will need chmod + x this, you can also set it as an environment variable, so you do not need to type a directory.

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

+5
source

How to save it to a file and using --askpass /your/file ? The option --askpass 2.0-beta20 was added in the OpenVPN version, Maverick has version 2.1.0-3ubuntu1 .

+4
source

I think you just swipe your finger on | and || .

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

|| run the second command only if the first command fails (exit code! = 0).

this command should work.

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

All Articles