Adding 400 users to local user manager

Started by Wyrm, July 19, 2018, 03:52:45 PM

Previous topic - Next topic
Quote from: fabian on September 03, 2018, 09:22:10 PM
a simple shell script adding one per row?
cat file.csv | while read line; do
c1=$(echo $line | cut -d',' -f1)
...
curl ... -H "Content-Type: application/json" --data "{json data}"
done;
I am sorry I do not much understand...I have .csv file and format of every row is:
username;e-mail;password;fullname
How will look whole script or where is command to add user?

I have PowerShell module by fvanroie and it only now connects to opnsense server by using api key and secret. Script he posted here is not adding any users. I tried to modify .csv file to only have password and username there and it did not helped.

So i do not know how to do it exactly...


Quote from: Wyrm on September 03, 2018, 09:45:46 PM
I am sorry I do not much understand...I have .csv file and format of every row is:
username;e-mail;password;fullname
username=$(echo $line | cut -d';' -f1)
mail=$(echo $line | cut -d';' -f2)
password=$(echo $line | cut -d';' -f3)
fullname=$(echo $line | cut -d';' -f4)

data extract from line is done - the rest is posting using curl. However this is shell scripting (Linux/BSD) and not Powershell.
the curl command only needs -u "user:password" (the two access token values) and the correct JSON structure like mentioned ealier.

Quote from: Wyrm on September 03, 2018, 09:45:46 PM
How will look whole script or where is command to add user?

I think you can assemble the parts now ;)

Quote from: Wyrm on September 03, 2018, 09:45:46 PM
I have PowerShell module by fvanroie and it only now connects to opnsense server by using api key and secret. Script he posted here is not adding any users. I tried to modify .csv file to only have password and username there and it did not helped.

Mine is just a small hint for you to get it done :)
for example, instead of curl you can output the variable using echo $username to see the content. The JSON structure can be captured from the web interface (it is using the same api)

Is it usable for local system manager users?

Quote from: Wyrm on September 04, 2018, 01:06:28 AM
Is it usable for local system manager users?

No, only with Freeradius plugin.
What exactly do you want to achieve with these local users?

September 04, 2018, 08:10:48 AM #19 Last Edit: September 04, 2018, 08:26:17 AM by Wyrm
I need them to login to captive portal and later for more services.
They also will have access to gui to change passwords and other aspects.
Customer does not have any windows server to hold their users and need to use these users to connect to his wifi and needs to apply some filtering and proxy
I think is better to have them as local users because when they decide to use 2FA they could...

By shell is possible to add them by some batch ?

You have to pre-check for what exactly. Also when using OpenVPN Radius can be used. Only downside would be you won't get a a client certificate for each user.

Captive Portal and OpenVPN with only user/pw is fine with Radius.

Better is not to use Radius. In future they may need certificates, because it is school and there is now strong impact on security (EU GDPR)...

Is there some option to do by some script anything for users in local manager?
When I save configuration - it is in XML. There is part in system tree in xml and it cointaints users...
Format is like this:
<user>
      <password>password</password>
      <scope>user</scope>
      <name>name</name>
      <descr>some descript</descr>
      <expires/>
      <authorizedkeys/>
      <ipsecpsk/>
      <otp_seed/>
      <email>some@some.xx</email>
      <uid>user id number</uid>
</user>
   
So is possible to have some import option to make xml file with this structure to add users?