Convert WPA_passphrase output to /etc/network/interface
Clash Royale CLAN TAG#URR8PPP
up vote
3
down vote
favorite
This is primarily a formatting problem which I haven't been able to solve well.
I want to create a bash function or script which converts output from wpa-passphrase to a format that can be used by /etc/network/interfaces.
Example WPA-Supplicant
wpa_passphrase ssid password
Produces the following output
network=
ssid="MYSSID"
#psk="passphrase"
psk=ccb290fd4fe6b22935cbae31449e050edd02ad44627b16ce0151668f5f53c01b
I need to convert that output to a format which can be used by /etc/network/interfaces
Example of the /etc/network/interface output format:
auto wlan0
iface wlan0 inet dhcp
wpa-ssid MYSSID
wpa-psk ccb290fd4fe6b22935cbae31449e050edd02ad44627b16ce0151668f5f53c01b
My first crude solution was to use:
wpa_passphrase MYSSID PASSWORD |grep -E 'ssid|psk' |grep -v "#psk" |cut -d '=' -f 2
Which gives me:
MYSSID
ccb290fd4fe6b22935cbae31449e050edd02ad44627b16ce0151668f5f53c01b
but I don't know how to get each of those lines into their proper place in the /etc/network/interfaces format
UPDATE: With my current solution
After further attempts I managed to get it to work with this:
while read line
do
echo "auto wlp3s0"
echo "iface wlp3s0 inet dhcp"
echo -e "t wpa-ssid $line"
done < <(sudo wpa_passphrase $1 $2 |grep -E 'ssid' |cut -d '=' -f 2)
while read line
do
echo -e "t wpa-psk $line"
done < <(sudo wpa_passphrase $1 $2 |grep -E 'psk' |grep -v "#psk" |cut -d '=' -f 2)
My solution gives the output I need, but it does not seem efficient and I would still like to see other solutions.
shell-script awk text-formatting
add a comment |Â
up vote
3
down vote
favorite
This is primarily a formatting problem which I haven't been able to solve well.
I want to create a bash function or script which converts output from wpa-passphrase to a format that can be used by /etc/network/interfaces.
Example WPA-Supplicant
wpa_passphrase ssid password
Produces the following output
network=
ssid="MYSSID"
#psk="passphrase"
psk=ccb290fd4fe6b22935cbae31449e050edd02ad44627b16ce0151668f5f53c01b
I need to convert that output to a format which can be used by /etc/network/interfaces
Example of the /etc/network/interface output format:
auto wlan0
iface wlan0 inet dhcp
wpa-ssid MYSSID
wpa-psk ccb290fd4fe6b22935cbae31449e050edd02ad44627b16ce0151668f5f53c01b
My first crude solution was to use:
wpa_passphrase MYSSID PASSWORD |grep -E 'ssid|psk' |grep -v "#psk" |cut -d '=' -f 2
Which gives me:
MYSSID
ccb290fd4fe6b22935cbae31449e050edd02ad44627b16ce0151668f5f53c01b
but I don't know how to get each of those lines into their proper place in the /etc/network/interfaces format
UPDATE: With my current solution
After further attempts I managed to get it to work with this:
while read line
do
echo "auto wlp3s0"
echo "iface wlp3s0 inet dhcp"
echo -e "t wpa-ssid $line"
done < <(sudo wpa_passphrase $1 $2 |grep -E 'ssid' |cut -d '=' -f 2)
while read line
do
echo -e "t wpa-psk $line"
done < <(sudo wpa_passphrase $1 $2 |grep -E 'psk' |grep -v "#psk" |cut -d '=' -f 2)
My solution gives the output I need, but it does not seem efficient and I would still like to see other solutions.
shell-script awk text-formatting
add a comment |Â
up vote
3
down vote
favorite
up vote
3
down vote
favorite
This is primarily a formatting problem which I haven't been able to solve well.
I want to create a bash function or script which converts output from wpa-passphrase to a format that can be used by /etc/network/interfaces.
Example WPA-Supplicant
wpa_passphrase ssid password
Produces the following output
network=
ssid="MYSSID"
#psk="passphrase"
psk=ccb290fd4fe6b22935cbae31449e050edd02ad44627b16ce0151668f5f53c01b
I need to convert that output to a format which can be used by /etc/network/interfaces
Example of the /etc/network/interface output format:
auto wlan0
iface wlan0 inet dhcp
wpa-ssid MYSSID
wpa-psk ccb290fd4fe6b22935cbae31449e050edd02ad44627b16ce0151668f5f53c01b
My first crude solution was to use:
wpa_passphrase MYSSID PASSWORD |grep -E 'ssid|psk' |grep -v "#psk" |cut -d '=' -f 2
Which gives me:
MYSSID
ccb290fd4fe6b22935cbae31449e050edd02ad44627b16ce0151668f5f53c01b
but I don't know how to get each of those lines into their proper place in the /etc/network/interfaces format
UPDATE: With my current solution
After further attempts I managed to get it to work with this:
while read line
do
echo "auto wlp3s0"
echo "iface wlp3s0 inet dhcp"
echo -e "t wpa-ssid $line"
done < <(sudo wpa_passphrase $1 $2 |grep -E 'ssid' |cut -d '=' -f 2)
while read line
do
echo -e "t wpa-psk $line"
done < <(sudo wpa_passphrase $1 $2 |grep -E 'psk' |grep -v "#psk" |cut -d '=' -f 2)
My solution gives the output I need, but it does not seem efficient and I would still like to see other solutions.
shell-script awk text-formatting
This is primarily a formatting problem which I haven't been able to solve well.
I want to create a bash function or script which converts output from wpa-passphrase to a format that can be used by /etc/network/interfaces.
Example WPA-Supplicant
wpa_passphrase ssid password
Produces the following output
network=
ssid="MYSSID"
#psk="passphrase"
psk=ccb290fd4fe6b22935cbae31449e050edd02ad44627b16ce0151668f5f53c01b
I need to convert that output to a format which can be used by /etc/network/interfaces
Example of the /etc/network/interface output format:
auto wlan0
iface wlan0 inet dhcp
wpa-ssid MYSSID
wpa-psk ccb290fd4fe6b22935cbae31449e050edd02ad44627b16ce0151668f5f53c01b
My first crude solution was to use:
wpa_passphrase MYSSID PASSWORD |grep -E 'ssid|psk' |grep -v "#psk" |cut -d '=' -f 2
Which gives me:
MYSSID
ccb290fd4fe6b22935cbae31449e050edd02ad44627b16ce0151668f5f53c01b
but I don't know how to get each of those lines into their proper place in the /etc/network/interfaces format
UPDATE: With my current solution
After further attempts I managed to get it to work with this:
while read line
do
echo "auto wlp3s0"
echo "iface wlp3s0 inet dhcp"
echo -e "t wpa-ssid $line"
done < <(sudo wpa_passphrase $1 $2 |grep -E 'ssid' |cut -d '=' -f 2)
while read line
do
echo -e "t wpa-psk $line"
done < <(sudo wpa_passphrase $1 $2 |grep -E 'psk' |grep -v "#psk" |cut -d '=' -f 2)
My solution gives the output I need, but it does not seem efficient and I would still like to see other solutions.
shell-script awk text-formatting
shell-script awk text-formatting
edited Aug 30 at 23:06
jww
1,45732155
1,45732155
asked Aug 29 at 0:49
Jay Hawk
285
285
add a comment |Â
add a comment |Â
1 Answer
1
active
oldest
votes
up vote
3
down vote
accepted
You can make a function as below and use awk
to format the output as you want:
generate()
sudo wpa_passphrase "$1" "$2"
Then call generate "my SSID" "PASSWORD"
.
Output would be:
auto wlan0
iface wlan0 inet dhcp
wpa-ssid "my SSID"
wpa-psk ccb290fd4fe6b22935cbae31449e050edd02ad44627b16ce0151668f5f53c01b
add a comment |Â
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
3
down vote
accepted
You can make a function as below and use awk
to format the output as you want:
generate()
sudo wpa_passphrase "$1" "$2"
Then call generate "my SSID" "PASSWORD"
.
Output would be:
auto wlan0
iface wlan0 inet dhcp
wpa-ssid "my SSID"
wpa-psk ccb290fd4fe6b22935cbae31449e050edd02ad44627b16ce0151668f5f53c01b
add a comment |Â
up vote
3
down vote
accepted
You can make a function as below and use awk
to format the output as you want:
generate()
sudo wpa_passphrase "$1" "$2"
Then call generate "my SSID" "PASSWORD"
.
Output would be:
auto wlan0
iface wlan0 inet dhcp
wpa-ssid "my SSID"
wpa-psk ccb290fd4fe6b22935cbae31449e050edd02ad44627b16ce0151668f5f53c01b
add a comment |Â
up vote
3
down vote
accepted
up vote
3
down vote
accepted
You can make a function as below and use awk
to format the output as you want:
generate()
sudo wpa_passphrase "$1" "$2"
Then call generate "my SSID" "PASSWORD"
.
Output would be:
auto wlan0
iface wlan0 inet dhcp
wpa-ssid "my SSID"
wpa-psk ccb290fd4fe6b22935cbae31449e050edd02ad44627b16ce0151668f5f53c01b
You can make a function as below and use awk
to format the output as you want:
generate()
sudo wpa_passphrase "$1" "$2"
Then call generate "my SSID" "PASSWORD"
.
Output would be:
auto wlan0
iface wlan0 inet dhcp
wpa-ssid "my SSID"
wpa-psk ccb290fd4fe6b22935cbae31449e050edd02ad44627b16ce0151668f5f53c01b
edited Aug 31 at 3:06
answered Aug 29 at 4:55
ñÃÂsýù÷
15.9k92563
15.9k92563
add a comment |Â
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f465405%2fconvert-wpa-passphrase-output-to-etc-network-interface%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password