How to access the Wi-Fi password through Terminal?
security find-generic-password -D &quot;AirPort network password&quot; -a $SSID -g | grep &quot;password:&quot;

Replace $SSID with the SSID of the network that you wish to obtain the key of.
This command looks for all keys with a type of &quot;AirPort network password&quot; and searches for the key with the name of the SSID that you provide.