LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 11-25-2012, 09:41 PM   #1
akashdeep
LQ Newbie
 
Registered: Mar 2009
Posts: 2

Rep: Reputation: 0
Smile Shell Script of Automating Client key generating


Hello Team,

I need a help in creating shell script for automating the generation of VPN client key for Open Vpn Server. The server is in configured on a Debian box.

There I can see lot of questions while I tried to create a client key such as

o Country Name [IN]:
o State or Province (full Name): MH:
o Locality Name [Mumbai]:
o Organization Name []:
o Organization Unit Name:
o Common name :
o Name []:
o Email Address:
o Please enter the following 'extra attributes to be sent with your certificate request
o A challenge password: <Any Random>
o An optional company name:
o Sign the certificate? [y/n]: <Enter ‘y’>
o 1out of 1 certificate requests certified, commit? [y/n] <Enter ‘y’>

All the answers of the above questions are stored in a file in the same order.

I would like to automate the process by executing a shell. Please help me to sort it out

Thanks in advance..
 
Old 11-25-2012, 10:32 PM   #2
Berhanie
Senior Member
 
Registered: Dec 2003
Location: phnom penh
Distribution: Fedora
Posts: 1,625

Rep: Reputation: 165Reputation: 165
you could start by looking at the req man page. look in the EXAMPLES section for "Sample configuration containing all field values". the idea is that you start with a config file (e.g. user.cnf) which would have all the values (CN, emailAddress, etc.) filled in. then you'd run "openssl req -config /path/to/user.cnf" to generate a csr, which you'd need to sign according to your requirements. following this procedure would entail generating a config file for each user, because you'd probably want certs with the user identity in the CN, but req also allows you to specify values on the command line.

Last edited by Berhanie; 11-25-2012 at 10:36 PM.
 
1 members found this post helpful.
Old 11-25-2012, 11:46 PM   #3
akashdeep
LQ Newbie
 
Registered: Mar 2009
Posts: 2

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by Berhanie View Post
you could start by looking at the req man page. look in the EXAMPLES section for "Sample configuration containing all field values". the idea is that you start with a config file (e.g. user.cnf) which would have all the values (CN, emailAddress, etc.) filled in. then you'd run "openssl req -config /path/to/user.cnf" to generate a csr, which you'd need to sign according to your requirements. following this procedure would entail generating a config file for each user, because you'd probably want certs with the user identity in the CN, but req also allows you to specify values on the command line.
Hello Berhanie,

Thanks for the quick response, could you please elaborate the details, if you can add an example it would be grateful.
 
Old 11-26-2012, 01:44 AM   #4
Berhanie
Senior Member
 
Registered: Dec 2003
Location: phnom penh
Distribution: Fedora
Posts: 1,625

Rep: Reputation: 165Reputation: 165
To read the examples i mentioned in the man page, you need to type
Code:
man req
But here is something you can try on the command line which does not require editing anything
Code:
openssl req -subj '/countryName=IN/stateOrProvinceName=MH/localityName=Mumbai/organizationName=mycompany/organizationalUnitName=IT Dept/commonName=Akashdeep Something/emailAddress=akashdeep@somewhere/' -new -nodes -newkey rsa:2048 -keyout akashdeep.key -out akashdeep.csr
This will generate a private key akashdeep.key and a csr (certificate signing request) akashdeep.csr. For openvpn, you will need some CA which signs all the user certs and the server cert. You'll have to read about setting up the CA* and using it to sign the CSRs, but everything can be automated. (*In fact, I think the self-signed cert you created in your first post is intended to be the CA cert).

By the way, you can see what's in your key and csr by using these commands:
Code:
openssl rsa -text -in akashdeep.key
Code:
openssl req -text -in akashdeep.csr
Also note that the procedure outlined above generates a non-encrypted key because of the nodes option.

Last edited by Berhanie; 11-26-2012 at 02:01 AM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Automating sftp using a shell script bhandu Linux - Newbie 3 07-17-2007 01:56 AM
automating lynx in a shell script yimboli Programming 15 04-04-2007 02:15 AM
Automating FTP upload via a shell script? Spitty Programming 5 01-16-2006 10:28 PM
Trouble when automating ftp with shell script hari_s_82 Linux - Newbie 2 09-23-2004 02:17 AM
Automating a playlist using shell script... DesiLILO Linux - Newbie 4 04-02-2004 11:03 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 07:11 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration