Improving Security for Public Wi-Fi: A Guide for Safe Connection Oversight

Improving Security for Public Wi-Fi: A Guide for Safe Connection Oversight

Improving Security for Public Wi-Fi: A Guide for Safe Connection Oversight


# Safeguarding Your Mac: Streamlining the Erasure of Insecure Wi-Fi Networks

In the contemporary digital world, the ease of linking to public Wi-Fi networks frequently brings along notable security vulnerabilities. Whether you utilize a personal Mac or supervise a batch of devices in a corporate setting with endpoint solutions like Mosyle, it is essential to recognize the risks that unsecured wireless networks may present. Numerous users inadvertently save these networks, for instance, “Starbucks WiFi” or “Airport Guest,” which can be manipulated by cybercriminals.

## The Dangers of Unsecured Wi-Fi Networks

Cyber attackers can establish rogue access points that replicate legitimate networks, deceiving devices into connecting without hesitation. This strategy is commonly used in man-in-the-middle (MitM) attacks, where the perpetrator captures data flowing between the victim’s device and the internet. A well-known tool for such attacks is the Wi-Fi Pineapple, capable of easily transmitting counterfeit networks with familiar SSIDs. Users might not detect the change, thinking they are linked to a trusted network, while their information is compromised.

Even though such attacks may not be highly prevalent, they pose a genuine risk worth acknowledging. Thankfully, there are actions you can take to reduce this risk, such as automating the deletion of common unsecured networks from your Mac.

## Streamlining the Deletion of Unsecured Networks

To assist you in securing your Mac, we offer a straightforward shell script that automates the deletion of unsecured Wi-Fi networks. Follow these steps to create and run the script:

### Step 1: Launch Terminal

Start by launching the Terminal application on your Mac. This application is located within the Utilities folder in Applications.

### Step 2: Generate the Script File

Next, generate a new script file using your chosen text editor. For this demonstration, we’ll use Nano:

“`bash
nano remove_public_wifi.sh
“`

### Step 3: The Script

Copy and paste the following script into your newly created `remove_public_wifi.sh` file. You can adjust the list of SSIDs as needed:

“`bash
#!/bin/bash

#############
# By Arin Waichulis
# Created 09/08/2024
# Last tested on 03/14/2025 with macOS Sequoia 15.4
#############

for interface in $(networksetup -listnetworkserviceorder | grep Hardware | awk ‘/Wi-Fi/ { print $NF }’ | awk -F “)” ‘{ print $1 }’)
do
echo “Now removing saved Wi-Fi networks from $interface”
networksetup -removepreferredwirelessnetwork $interface “Starbucks WiFi”
networksetup -removepreferredwirelessnetwork $interface “Starbucks”
networksetup -removepreferredwirelessnetwork $interface “Panera”
networksetup -removepreferredwirelessnetwork $interface “CVG Free”
networksetup -removepreferredwirelessnetwork $interface “FreeWiFi”
networksetup -removepreferredwirelessnetwork $interface “SFO WiFi”
networksetup -removepreferredwirelessnetwork $interface “Public Free”
networksetup -removepreferredwirelessnetwork $interface “Airport-WiFi”
networksetup -removepreferredwirelessnetwork $interface “DaysInn_Guest”
networksetup -removepreferredwirelessnetwork $interface “Free-Network”
done

exit 0
“`

### Step 4: Save and Exit

To save the file in Nano, press `Ctrl + O`, then hit `Enter` to confirm the filename. Exit the editor by pressing `Ctrl + X`.

### Step 5: Grant Executable Permissions

Before executing the script, you must assign it executable permissions. Use the following command:

“`bash
chmod +x remove_public_wifi.sh
“`

### Step 6: Execute the Script

Finally, run the script by entering the following command and authenticating as `sudo`:

“`bash
sudo ./remove_public_wifi.sh
“`

This will stop your Mac from automatically linking to any of the specified unsecured networks. Although you can also manually delete these networks through the Wi-Fi settings, using the script is a more efficient solution, particularly for frequent travelers or corporate environments.

## Conclusion

By automating the elimination of unsecured Wi-Fi networks, you can considerably bolster the security of your Mac. Understanding the risks associated with public Wi-Fi and taking proactive steps can help safeguard your sensitive information from potential attackers. If you have any inquiries or require further assistance, feel free to leave a comment below!

For additional information on securing your Apple devices, consider exploring the solutions provided by Mosyle, a leader in Apple device management and security.