On Mac OS, you should execute:
security find-generic-password -D "AirPort network password" -a $SSID -g | grep "password:"
On Linux, you should execute:
sudo cat /etc/NetworkManager/system-connections/{$SSID}.nmconnection | grep "psk="
On Mac OS, you should execute:
security find-generic-password -D "AirPort network password" -a $SSID -g | grep "password:"
On Linux, you should execute:
sudo cat /etc/NetworkManager/system-connections/{$SSID}.nmconnection | grep "psk="