Sunday, May 5, 2024
 Popular · Latest · Hot · Upcoming
3
rated 0 times [  3] [ 0]  / answers: 1 / hits: 490  / 3 Years ago, mon, may 24, 2021, 1:43:31

I need to configure a set of new machines. They all need a set of common WLAN connections I currently have on my machine. I know how to manually retrieve the settings including the passwords using the network-manager GUI.



What I'm looking for are 2 scripts: one to extract all wireless settings (at least SSID and security type/password) into a text format file (XML would be fine), so I can edit and polish it. The other one (unsurprisingly) to write them back (on a new machine).



Any pointers are welcome!



Clarification: I don't want to snoop out passwords in the wireless world, just to ease the process of documenting and distributing what is stored on one machine already.


More From » wireless

 Answers
1

It turns out, a simple copy operation will suffice! With a little more snooping around on askUbuntu it turns out that all network connections are stored in /etc/NetworkManager/system-connections/, so I just need to copy them (root access required) around using any of the distribution methods I'd pick.



To document the settings (we love spreadsheets) a simple script (solved with a little help) one can use this script:



#!/bin/bash
#Document wifi passwords
echo ssid,password > knownwifi.csv
for f in /etc/NetworkManager/system-connections/*
do
ssid=$(awk -F= '$1=="ssid" {print $2}' "$f")
pwd=$( awk -F= '$1=="psk" {print $2}' "$f")
#We are only interested in password protected Wifi
if [ x$pwd != 'x' ]
then
echo "$ssid,$pwd"
fi
done >> knownwifi.csv
echo done


You need to run that script as root and you might want to add additional values from connection setting. Opens nicely in a spreadsheet of your choice


[#30404] Wednesday, May 26, 2021, 3 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
antebrow

Total Points: 291
Total Questions: 135
Total Answers: 117

Location: New Caledonia
Member since Thu, Mar 23, 2023
1 Year ago
antebrow questions
;