I want shell scripts to be able to generate easy-rsa client certificates

Asked 2 years ago, Updated 2 years ago, 74 views

I'm a beginner in shellscript.

When creating a client certificate with easy-rsa for OpenVPN, I wrote the following code so that it could be executed in shellscript:

#!/bin/bash
expect-c"
set timeout5
spawn env LANG = C/etc/openvpn/easy-rsa/pkitool --pass test_client01
expect\"Enter PEM pass phase:\"
send\"hoge\"
expect\"Verifying-Enter PEM pass phase:\"
send\"hoge\"
"

Normally, this command should generate test_client01.crt, test_client01.key, test_client01.csr files below ./keys/, but somehow only .key files are generated when you run the above command.

Eventually, we plan to spin around files with about 100 passwords so that we can easily create multiple client certificates.

It may be the lack of knowledge on the easy-rsa side, not the shell, but please let me know if there is anything wrong with the code.

bash shellscript expect vpn

2022-09-30 17:36

1 Answers

I think a new line is needed at the end of the password, so

send\"hoge\"

where

send\"hoge\\r\"

I think so.


2022-09-30 17:36

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.