You are not logged in.

#1 2015-08-11 21:09:13

darkmav
Member
Registered: 2012-01-21
Posts: 127

Porting a script from wpa_cli to nmcli

I have a method to connect to a MSCHAPv2-based secure WiFi network, as outlined on this link. It uses wpa_cli.

A downside of this method is that there is no GUI notification applet to work with it, and it is also not automated. While it may be possible to run this script at startup and take care of the automation issue, the lack of GUI-based control is still a drawback.

Is there a way to get this script to work with nmcli instead?

Offline

#2 2015-08-11 21:25:43

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,538
Website

Re: Porting a script from wpa_cli to nmcli

What??  That script is ridiculous.  You know all it does is construct a wpa_supplicant.conf entry - there is absolutely no need whatsoever to call wpa_cli in that script.  Certainly not a dozen or so times in a row.

I don't use nmcli, but it also just makes entries for wpa_supplicant.  So just take the settings that work, and put them in the proper nmcli file/profile/whatever.

Also, I don't know what to make about all that noise at the top of the blog you link to where the author says that the settings needed are not preferred by the archlinux community.  The archlinux community certainly does not have anything against configuring ones network so it works.  For a specific example of a working MSCHAPv2 configuration see the second example provided in `man wpa_supplicant.conf`.


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#3 2015-08-11 21:50:54

darkmav
Member
Registered: 2012-01-21
Posts: 127

Re: Porting a script from wpa_cli to nmcli

I want to respectfully point out that even with Network Manager, the connection drops frequently and it is only with those wpa_cli commands does the network work reliably. If you have a scientific/technical answer to that, I will really appreciate you telling me about it.

Preceding wpa_cli with those commands is not the optimal way to run the script, but this is the only way on the systems on campus unless you run "chattr +i /etc/wpa_supplicant.conf" and prevent other applications or programs accidentally run as root from modifying the script. The original solution was to start wpa_cli and enter those commands manually. But this had to be done again if the network were to disconnect for some reason (or the wifi-kill switch pressed).

Instead of making personal attacks, you should probably try to learn about the problem before passing judgment. The campus network does not work reliably with anything but that script. I know it is not the best solution, but it is somewhat unscientific of you to attack a solution that exists and works without even knowing the problems with what you suggest. Anyway I do not want to indulge in a battle, so I will assume that you are simply reacting to the non-optimal nature of the script rather than anything else.

Finally, I think there is some comprehension error in interpreting that the Arch Linux community is 'against' MSCHAPv2. What is stated is that there is no obvious out of the box support for this, and given that wifi-menu fails to connect, you should know that it is not possible to install Arch Linux on a system constrained to connect to such a network unless you first use these commands (not the script, mind you) or connect the system to an open wifi network, install Arch and then configure Network Manager.

For now, I am using Network Manager in plasma after having installed Arch Linux on the secure wifi using this method. The connection drops every now and then (something that didn't happen with wpa_cli/netctl) but I'm making do with it. Thank you for your comments!

Last edited by darkmav (2015-08-11 21:52:37)

Offline

#4 2015-08-11 21:57:05

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,538
Website

Re: Porting a script from wpa_cli to nmcli

I'm sorry you see me as unscientific.  There is nothing personal about knowing how wpa_cli works.  It creates and entry in wpa_supplicant.conf that's it.  If you put that entry in wpa_supplicant.conf yourself, instead of executing a dozen wpa_cli commands, it will have exactly the same result.  I don't care who you think this is a personal attack on - this is simply how that program works.  But if you don't actually want to learn how to replicate these same settings without using wpa_cli, then I have no idea what this thread is for, and I'll leave you to yourself.


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#5 2015-08-11 21:59:55

darkmav
Member
Registered: 2012-01-21
Posts: 127

Re: Porting a script from wpa_cli to nmcli

Thanks for your reply Trilby. My point is that wpa_supplicant.conf seems to be getting modified and those settings deleted from time to time. If you have a solution to figuring out how this happens and a way to stop it, I will definitely appreciate your inputs. Secondly, I only tried to tell you that the script (with all its stupidities) works. Calling it ridiculous does not solve the problem.

You say "But if you don't actually want to learn how to replicate these same settings without using wpa_cli, then I have no idea what this thread is for, and I'll leave you to yourself."

(1) If I claimed to be an expert who figured it out, I would not have posted a question on the Newbie forum...

(2) I am fairly new to Arch which is to say that I run into problems and learn from people like you on this forum or elsewhere on the internet, but I have been on forums and have used other distros (maybe "easier" ones for people like me with lower propensity to hack?) for a long time. And it may be my personal isolated opinion, but I find such hostility on the forums somewhat disturbing given the free nature of Linux. Of course, I completely apologize if you feel it was I who took your first comment more sensitively as an attack, and of course, I am all for a heated argument :-). But I hope you see my point as well. <Now I just saw your other message which I'll reply to..>

Last edited by darkmav (2015-08-11 22:04:20)

Offline

#6 2015-08-11 22:02:52

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,538
Website

Re: Porting a script from wpa_cli to nmcli

darkmav wrote:

My point is that wpa_supplicant.conf seems to be getting modified and those settings deleted from time to time.

By what / whom?  Are you sharing this computer with others?

If nothing else, you could maintain the entry for the wpa_supplicant somewhere else in your own config file just for that network.  Wpa_supplicant does not need to use the config file in /etc/wpa_supplicant/ it will use whatever file is passed on the command line.  I *think* networkmanager/nmcli uses some sort of profiles for this actually, but I've never used nmcli.

My whole point is that starting with that script is the wrong place to start.  The real question here is how to get nmcli to use specific wpa_supplicant settings, right?


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#7 2015-08-11 22:08:49

darkmav
Member
Registered: 2012-01-21
Posts: 127

Re: Porting a script from wpa_cli to nmcli

Trilby wrote:
darkmav wrote:

My point is that wpa_supplicant.conf seems to be getting modified and those settings deleted from time to time.

By what / whom?  Are you sharing this computer with others?

I am not sharing it with others, but it beats me why the file contents get refreshed after a reboot, especially when NetworkManager isn't installed (and no other program is being run that I know of, which would try to modify this file).

Trilby wrote:

If nothing else, you could maintain the entry for the wpa_supplicant somewhere else in your own config file just for that network.  Wpa_supplicant does not need to use the config file in /etc/wpa_supplicant/ it will use whatever file is passed on the command line.  I *think* networkmanager/nmcli uses some sort of profiles for this actually, but I've never used nmcli.

My whole point is that starting with that script is the wrong place to start.  The real question here is how to get nmcli to use specific wpa_supplicant settings, right?

Yes, that is the real question.

Well, unfortunately after trying almost everything on the internet, wpa_cli was the only way to even connect to this network. So for now, I have saved the commands I need to pass to wpa_cli in my own "script" (perhaps a dangerous word to use :-)).

So going back to square one,

(1) Who/what is modifying the wpa_supplicant.conf file if (a) I am the only one using the system, and (b) the only thing being used is wpa_cli.
(2) When Network Manager is used, why is the connection shaky?

Offline

#8 2015-08-11 22:13:26

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,538
Website

Re: Porting a script from wpa_cli to nmcli

For (2) are you sure there are no other network services running?  Competing network services are the #1 cause of unstable connections.

For (1), either there is some other network service running that is rewriting wpa_supplicant.conf, or some-one is hacking into your system just to mess with you (I find this highly highly unlikely).

But again, rather than using all those wpa_cli commands, just create the entry for the wpa_supplicant configuration file.  While you figure out what is overwriting your changes, you could have a file at ~/my_wpa and just use that as the configuration file.


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

Board footer

Powered by FluxBB