Posts Tagged ‘password’

Leopard VNC Server Serial Number Password

VNC GuestDigging around in a NetBoot-Install.dmg file created by NetRestore Helper, I found a nice little gem.

In Leopard, and perhaps earlier versions of Mac OS X, we’re able to start a VNC server with the machine serial number as a password. This is particularly interesting for a managed network or lab environment.

As an example, I’m starting a VNC server in my NetBoot-Install image with the following shell script:

# Credit to Mike Bombich for this snippet

VNC="/System/Library/CoreServices/RemoteManagement/AppleVNCServer.bundle/Contents/MacOS/AppleVNCServer"

if [ -x "$VNC" ]; then
    "$VNC" -noRegister -serialNumber &
fi

I’m then able to quickly connect with Cmd+K in the finder:
Connect to Server

If you’re scripting this, here’s a quick way to snag the serial number. I do this before I bless a client machine to netboot, so I have the serial number to connect back up once it’s in the NetRestore system.

system_profiler SPHardwareDataType | \
  grep -i 'serial number' | \
  perl -ple 's/.*:\s+(\w+).*?/$1/'
 

Show Password from System keychain

Keychain UnlockedI tried retrieving the password for a wireless network I’d joined sometime in the past. To do this, I went into Keychain Access, selected the System keychain, and asked it to Show Password for the networking in question.

As it turns out, the system keychain is protected with a shared secret which I believe is maintained in /var/db/SystemKey. This is a binary file, so it’s not very easy to pull out the password in a form that can be entered in the dialog box Keychain Access presents.

As a work around, I found a nice hint [1] that uses Keychain Scripting to copy the password to the clipboard. Here’s the Apple Script I’m using. Please not that the first character of a WEP key appears to be $, which should be discarded.

display dialog "What key?" default answer ""
set theKeyName to the text returned of the result
tell application "Keychain Scripting"
	tell keychain "System.keychain"
		set theKeyList to every key
		repeat with k in theKeyList
			if the name of k is theKeyName then
				set TheKeyValue to the password of k
			end if
		end repeat
	end tell
end tell

set the clipboard to TheKeyValue

display dialog "Copied " & length of TheKeyValue & " chars to clipboard." with icon note buttons {"OK"} default button "OK"

[1] 10.4: AirPort and System.keychain password solution