networksetup

Configuration tool for Network System Preferences. More information: https://support.apple.com/guide/remote-desktop/about-networksetup-apdd0c5a2d5/mac.

networksetup -listallnetworkservices

networksetup -getinfo "Wi-Fi"

networksetup -getairportnetwork en0

networksetup -setairportnetwork en0 Airport Network SSID password