LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   embed into ovpn client file (https://www.linuxquestions.org/questions/linux-newbie-8/embed-into-ovpn-client-file-4175667622/)

kzo81 01-13-2020 08:36 AM

embed into ovpn client file
 
Hi, I'd like to inline embed the ca.crt's data into the client.conf file like this:

Code:

cat base.conf
<(echo -e '<ca>') ~/client-configs/keys/ca.crt <(echo -e '</ca>')
<(echo -e '<cert>') ~/client-configs/keys/client1.crt <(echo -e '</cert>n')
<(echo -e '<key>') ~/client-configs/keys/client1.key <(echo -e '</key>n')
<(echo -e '<tls-auth>') ~/etc/openvpn/ta.key <(echo -e '</tls-auth>') >> client1.ovpn

But I got this error:
Code:

bash: /dev/fd/63: Permission denied
I did it as root. Obviously there us something going on wrong the way I try to embed in. Do you know how to do it properly?

eSelix 02-12-2020 11:47 AM

It should be in one line. Or use line continuation character at end of each line, it is backslash in Bash (\).

kzo81 02-12-2020 12:29 PM

This was the solution, thanks though

#!/bin/bash

f=$1

cat base.conf > client"$1".ovpn

echo <ca> >> client"$1".ovpn
cat ~/client-configs/keys/ca.crt >> client"$1".ovpn
echo </ca> >> client"$1".ovpn

etc...


All times are GMT -5. The time now is 03:29 PM.