Sign into WPA2 network that requires a username from mac terminal?

7,318

I wish networksetup had a username option

   networksetup en0 on
   networksetup -setairportnetwork en0 ssidHERE PSKpasswordHERE

per airport command in /System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources, it doesn't have a username flag ("airport -h" no help either):

   airport --password=PSKpasswordHERE --ssid=ssidHERE

SO, you could create an xml file (note GUI "Apple Configurator 2" app and new profile and configure wi-fi) with pico or something, and NOTE that I've way over-simplied what might be needed inside--not worth the effort compared to GUI join; but you now have the clues if you want to persue:

   <key>UserName</key>
   <string>yourUsernameHERE</string>
   <key>UserPassword</key>
   <string>yourPasswordHERE</string>
   <key>SSID_STR</key>
   <string>yourSsidHERE</string>

then run (note if sudo or as root, it will install for all users!):

   profiles -I yourxmlfileHERE
Share:
7,318

Related videos on Youtube

Boi Johnny
Author by

Boi Johnny

Updated on September 18, 2022

Comments

  • Boi Johnny
    Boi Johnny over 1 year

    I am trying to sign into my school's network through terminal. It has WPA2 security, however it requires that I put a username along with a password. Is this possible to do from terminal?

    Side note: When not using terminal, once you try to connect to the network it will just prompt the user for a username and password.

    --Also, when looking at the network setup help menu (networksetup -h) there is no option that resembles what I am trying to accomplish.

    • Kinnectus
      Kinnectus over 8 years
      Could you clarify what is prompting your username/password - an OS X popup (system window) or Safari (often showing your school's logo/wireless information)? The answers given depend on what you mean by "it will just prompt the user for a username and password"...
  • Kinnectus
    Kinnectus over 8 years
    Although the OPs question text doesn't specifically say whether EAP is used, it could also be assumed that because he's asked for a username/password that the school may be using WPA2 Enterprise where, say, they may be using a RADIUS server to authenticate users, which does have the ability to accept a username/password/hostname from the client. A captive portal is very feasible so I must give you credit (the lack of detail from the OP doesn't help). Although, due to the traction of RADIUS popularity, this sounds more like what's in place.
  • Kinnectus
    Kinnectus over 8 years
    Mac has a command line application "airport" that may be used to configure wireless settings through Terminal - I'm not a Mac user but this may help the OP.
  • Anti-weakpasswords
    Anti-weakpasswords over 8 years
    @Bigchris Agreed, it could be EAP, though "once you try to connect to the network it will just prompt the user for a username and password" sounds more like a captive portal to me, and "my school's" sounds like the OP is a student, and thus less likely to need to get onto an EAP network than a professor or other staff member.
  • Kinnectus
    Kinnectus over 8 years
    I work for a University and we use RADIUS (eduroam) and that's WPA2 Enterprise and all our students connect to it using their unique username/password. Staff can use it, too. I've also created a WPA2 Enterprise/RADIUS network for a client and that, too, uses user authentication to connect... It's not difficult to do and RADIUS is becoming an almost defacto method of business wireless nowadays...
  • Anti-weakpasswords
    Anti-weakpasswords over 8 years
    @Bigchris Your university handles security better than many, then, which is great!