Connect to an AirPort Network via the Command Line in Mac OS X

May 27, 2010 - Leave a Comment

You can connect to any wireless network from the command line by using the networksetup command as follows:
sudo networksetup -setairportnetwork en1 SSID PASSWORD

So in a practical example, let’s say we are connecting to a network named ‘Wireless’ and the password is set to ‘macsrule’ as so:
sudo networksetup -setairportnetwork en1 Wireless macsrule

As far as I know this is Snow Leopard only, but it may work on older versions of Mac OS X as well. You can read more about the networksetup command line tool on it’s Manual Page

Enjoy this tip? Subscribe to the OSXDaily newsletter to get more of our great Apple tips, tricks, and important news delivered to your inbox! Enter your email address below:

Related articles:

Posted by: David Mendez in Command Line

Leave a Reply


Shop for Apple & Mac Deals on

Subscribe to OSXDaily

Subscribe to RSS Subscribe to Twitter Feed Follow on Facebook Subscribe to eMail Updates