Retrieving wireless keys from the keychain on os x

October 17th, 2006

I usually travel with two laptops, a mac and a windows machine. My mac is my main machine and the PC is usually provided by work and often changes. More then once I’ve wanted to access a wireless network on the PC but the key on my mac was not accessible. This happened recently and instead of having someone dig up long lost key i searched around and found this applescript solution.

1
2
3
4
5
6
7
8
9
tell application "Keychain Scripting"
	tell keychain "System.keychain"
		set TheKey to "" & (password of first key whose name is "xxx")
	end tell
end tell
 
set the clipboard to TheKey
 
display dialog "Copied " & length of TheKey & " chars to clipboard." with icon note buttons {"OK"} default button "OK"

Replace xxx with your network name.

That script will copy whatever network’s key you specify to the clip board. A big help if you don’t have a key like “1234567890″.

Leave a Reply