README
NetworkManager Connection Sync Script
A script to Sync wifi passwords between machines.
This repository contains a simple set of shell commands used to export, sanitize, and re‑import NetworkManager connection profiles between a local system and a shared location.
It is intended for Linux systems using NetworkManager (e.g. Debian, Ubuntu, RHEL-family).
Purpose
- Back up NetworkManager .nmconnection profiles to a shared directory
- Remove host-specific fields (interface-name, uuid)
- Restore the cleaned profiles onto another system
- Reload NetworkManager connections safely
This allows reuse of connection profiles across machines without UUID or interface conflicts.
Directory Structure
.
└── Connections/
└── system-connections/
The Connections/system-connections/ directory must exist before running the export step.
Script Logic
1. Copy connections from local system to share
Shell
Show more lines
- Copies all NetworkManager connection profiles
- Temporarily relaxes permissions to allow editing and sharing
2. Clean and rebuild connections from share to local
Shell
Show more lines
Removes fields that must be regenerated per-host:
- interface-name (hardware specific)
- uuid (must be unique per system)
Shell
Show more lines
- Restores profiles to the correct system location
- Applies required ownership and permissions for NetworkManager
3. Reload NetworkManager
Shell
Show more lines
Reloads all connection profiles without restarting the NetworkManager service.
Requirements
- Linux with NetworkManager
- nmcli
- Root (sudo) access
- .nmconnection files (keyfile format)
Safety Notes
- Do not keep /etc/NetworkManager/system-connections/ world-writable
- Permissions must be:
- Mode: 600
- Owner: root:root
- Failure to do so may cause NetworkManager to ignore the profiles
Reference:
- NetworkManager keyfile permissions documentation
Typical Use Cases
- Provisioning identical network configs across multiple hosts
- Migrating Wi‑Fi / VLAN / VPN profiles
- Lab or cluster deployments
- Backup and restore of NetworkManager configs
Tested With
- Debian / Ubuntu
- NetworkManager keyfile backend
- Wired, Wi‑Fi, VLAN, and VPN profiles