Connect to Wi-Fi via command line that requires username and password I am trying to find the command to connect to a wireless access point that is WPA2, and requires both a username and password.

The command networksetup -setairportnetwork &lt;iface&gt; &lt;ssid&gt; &lt;pwd&gt; only works if I don't need a user name.
It does sound like you are trying to connect to an enterprise network and you have 802.11x authentication. 

If this is NOT the case and you need to enter a username/password in a web page, then you may need to create an AppleScript/Automator function to handle that.

In any event, to connect to an 802.11x network with authentication, you need a network profile.  To create one, you either need OS X Server or you can use Apple Configurator.  It's a free application available from Apple.

While it is geared toward iOS, you can create wi-fi profiles then export them.  Once you have the xml file, you import it with networksetup.

Or...

You can edit the xml file directly which is not something trivial.