Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Every time I try to find out how to do this, I find out how to do it on a linux, and it doesn't transfer. How do I connect to a WiFi network using Mac Terminal Bash?

share|improve this question

3 Answers 3

up vote 8 down vote accepted

As of Snow Leopard (Mac OS X v10.6.x) and possibly earlier, you can do:

networksetup -setairportnetwork $INTERFACE $SSID $PASSWORD

Where...

  • $INTERFACE is the "enX" style identifier for your AirPort card (usually en1, but it's en0 on MacBook Airs and en2 on Mac Pros, and can vary for other reasons as well)
  • $SSID is your network name, such as "Simon's SSID". Enclose it in quotes if it contains spaces.
  • $PASSWORD is your WEP, WPA-PSK, or WPA2-PSK password.

If you look at the man page or help/usage statement for networksetup you'll see that it has other AirPort-related subcommand for getting or setting the power state (AirPort card on/off), and for managing the Preferred Networks list and 802.1X profiles (if your network uses 802.1X, such as a WPA Enterprise or WPA2 Enterprise network would).

share|improve this answer

Figured it out:

sudo airport -A

share|improve this answer
1  
there is no "-A" option in airport –  Luxspes Sep 13 '13 at 18:34

Here is a little guide on using airport in the Command Line

Apparently you can use

$ airport 

as a command. I would try

$ airport -help

and see if it brings up some options.

This answer is outdated. Please ignore it

share|improve this answer
    
My SSID contains spaces, how would I enter it? –  JShoe May 20 '11 at 23:03
    
Put it into quotations. Like "Simon's SSID". So the command may be something like: airport -x "Simon's SSID" –  Simon Sheehan May 20 '11 at 23:06
    
make that /System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resourc‌​es/airport, on my computer, at least. –  Nathan Grigg May 21 '11 at 0:13
    
@Simon what would the -x do? @nathang why would it change? How do I find what the correct location on my computer would be? –  JShoe May 21 '11 at 3:05
    
How in the world did this answer, which has no hope of working, get upvotes? –  Spiff May 21 '11 at 3:56

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.