Ubuntu – Inputting input in a command?

command lineopenvpn

I'm running a command through a program that needs to create an OpenVPN account. After putting in this line to start making the account:

cd /etc/openvpn/easy-rsa; . ./vars; ./build-key username

I need to have it put in no input 10 times [like pressing enter,] and then press y twice. It needs to all be in this one line. Is this possible? Thanks in advance.

EDIT:

root@suffice-vpn:~# cd /etc/openvpn/easy-rsa; . ./vars; <<<$'\n\n\n\n\n\n\n\n\n\nyy' ./build-key username
NOTE: If you run ./clean-all, I will be doing a rm -rf on /etc/openvpn/easy-rsa/keys
Generating a 2048 bit RSA private key
..............+++
.....................+++
writing new private key to 'username.key'
-----
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [US]:State or Province Name (full name) [NY]:Locality Name (eg, city) [Merrick]:Organization Name (eg, company) [IceWare]:Organizational Unit Name (eg, section) [IceWare]:Common Name (eg, your name or your server's hostname) [username]:Name [server]:Email Address [iceware@programmer.net]:
Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []:An optional company name []:Using configuration from /etc/openvpn/easy-rsa/openssl-1.0.0.cnf
Check that the request matches the signature
Signature ok
The Subject's Distinguished Name is as follows
countryName           :PRINTABLE:'US'
stateOrProvinceName   :PRINTABLE:'NY'
localityName          :PRINTABLE:'Merrick'
organizationName      :PRINTABLE:'IceWare'
organizationalUnitName:PRINTABLE:'IceWare'
commonName            :PRINTABLE:'username'
name                  :PRINTABLE:'server'
emailAddress          :IA5STRING:'iceware@programmer.net'
Certificate is to be certified until Jan 14 16:59:03 2026 GMT (3650 days)
Sign the certificate? [y/n]:CERTIFICATE WILL NOT BE CERTIFIED: I/O error
root@suffice-vpn:/etc/openvpn/easy-rsa#

As you can see, it goes through the process filling in the blanks [keeping all that information that I want to remain the same] but then I get this I/O error.

Best Answer

  • I solved it by using this command:

    cd /etc/openvpn/easy-rsa; . ./vars; ./build-key --batch username