Wpa supplicant editing issue through telnet

Post new topic   Reply to topic    DD-WRT Forum Index -> Atheros WiSOC based Hardware
Author Message
Itsyaboy
DD-WRT User


Joined: 18 May 2016
Posts: 61

PostPosted: Sat Feb 18, 2017 8:55    Post subject: Wpa supplicant editing issue through telnet Reply with quote
Edit: last time I was here I didn’t understand much, pretty much still don’t lol, but I’ve found out there was a much easier way to do what I wanted, I have a new much simpler question on the last post so anyone who can help out y’all can skip everything else from 2 years ago.


So I have a tp link wr841n v9 flashed with DD-WRT v3.0-r31277 std (02/07/17) the problem is whenever I try to edit wpa supplicant through telnet with ( sed -i '7ibssid=XX:XX:XX:XX:XX:XX' /tmp/ath0_wpa_supplicant.conf ) it doesn't take and the line is not added same for when I add it as a custom script in administration, the only way I can add the line is if I use winscp and manually edit the file, only after I manually edit is when telnet works and I can add custom lines anybody know what's the issue ? It's annoying that I have to log into a windows machine to edit the file as I can't find an scp client app for Mac that is free.


Last edited by Itsyaboy on Wed Aug 18, 2021 0:49; edited 2 times in total
Sponsor
tatsuya46
DD-WRT Guru


Joined: 03 Jan 2010
Posts: 7568
Location: YWG, Canada

PostPosted: Sat Feb 18, 2017 10:27    Post subject: Reply with quote
there is some issues currently with hostapd, aka wpasupplicant, take what u find with a grain of salt. im currently in a "battle" with head developer, on fixing these issues, see http://svn.dd-wrt.com/timeline
_________________
LATEST FIRMWARE(S)

BrainSlayer wrote:
we just do it since we do not like any restrictions enforced by stupid cocaine snorting managers

[x86_64] Haswell i3-4150/QCA9984/QCA9882 ------> r55797 std
[QUALCOMM] DIR-862L --------------------------------> r55797 std
▲ ACTIVE / INACTIVE ▼
[QUALCOMM] WNDR4300 v1 --------------------------> r50485 std
[BROADCOM] DIR-860L A1 ----------------------------> r50485 std


Sigh.. why do i exist anyway.. | I love you Anthony.. never forget that.. my other 99% that ill never see again..

Itsyaboy
DD-WRT User


Joined: 18 May 2016
Posts: 61

PostPosted: Sun Feb 26, 2017 12:59    Post subject: Reply with quote
Ok thanx I'll give echo a try next time the router needs a reboot, although the sed does add lines, but only after I manually edit the file with winscp after it's manually edited it works fine but pointless afterwards since winscp got the job done already lol
And the line added is bssid=(Mac address) the mac address of the connection I want to stay locked on to, to prevent roaming.

So do I use that as is with the quotes ? And not sure what >> is


Last edited by Itsyaboy on Sun Feb 26, 2017 13:11; edited 1 time in total
tatsuya46
DD-WRT Guru


Joined: 03 Jan 2010
Posts: 7568
Location: YWG, Canada

PostPosted: Sun Feb 26, 2017 13:05    Post subject: Reply with quote
WAIT... much of what ur saying is all changed up from latest public build to latest nightly build.

install this latest r31495, THEN, test.. ONLY. accept this build in the event the small chance it may brick & will need to recover.

this is WEBFLASH build, NOT, tftp or initial flash! and this is for wr841ndv9. i posted this cause many things are being mentioned that are already fixed in trunk, "trunk" = latest nightly, svn build, not available to public users except a few.


if u dont believe me then DONT FLASH, PERIOD. I DONT WANT UR BLAMING CRAP IF UR A NOOB AT FLASHING A ROUTER!

_________________
LATEST FIRMWARE(S)

BrainSlayer wrote:
we just do it since we do not like any restrictions enforced by stupid cocaine snorting managers

[x86_64] Haswell i3-4150/QCA9984/QCA9882 ------> r55797 std
[QUALCOMM] DIR-862L --------------------------------> r55797 std
▲ ACTIVE / INACTIVE ▼
[QUALCOMM] WNDR4300 v1 --------------------------> r50485 std
[BROADCOM] DIR-860L A1 ----------------------------> r50485 std


Sigh.. why do i exist anyway.. | I love you Anthony.. never forget that.. my other 99% that ill never see again..

Itsyaboy
DD-WRT User


Joined: 18 May 2016
Posts: 61

PostPosted: Sun Feb 26, 2017 13:19    Post subject: Reply with quote
Thanx I'll give that a try if the echo code doesn't work
Itsyaboy
DD-WRT User


Joined: 18 May 2016
Posts: 61

PostPosted: Sun Feb 26, 2017 13:39    Post subject: Reply with quote
tatsuya46 wrote:
WAIT... much of what ur saying is all changed up from latest public build to latest nightly build.

install this latest r31495, THEN, test.. ONLY. accept this build in the event the small chance it may brick & will need to recover.

this is WEBFLASH build, NOT, tftp or initial flash! and this is for wr841ndv9. i posted this cause many things are being mentioned that are already fixed in trunk, "trunk" = latest nightly, svn build, not available to public users except a few.


if u dont believe me then DONT FLASH, PERIOD. I DONT WANT UR BLAMING CRAP IF UR A NOOB AT FLASHING A ROUTER!


wait are you saying i should install that before trying anything else ?
tatsuya46
DD-WRT Guru


Joined: 03 Jan 2010
Posts: 7568
Location: YWG, Canada

PostPosted: Sun Feb 26, 2017 13:48    Post subject: Reply with quote
Itsyaboy wrote:
tatsuya46 wrote:
WAIT... much of what ur saying is all changed up from latest public build to latest nightly build.

install this latest r31495, THEN, test.. ONLY. accept this build in the event the small chance it may brick & will need to recover.

this is WEBFLASH build, NOT, tftp or initial flash! and this is for wr841ndv9. i posted this cause many things are being mentioned that are already fixed in trunk, "trunk" = latest nightly, svn build, not available to public users except a few.


if u dont believe me then DONT FLASH, PERIOD. I DONT WANT UR BLAMING CRAP IF UR A NOOB AT FLASHING A ROUTER!


wait are you saying i should install that before trying anything else ?


correct. lots of 2.4 ghz changes. lots of 5ghz changes. openvpn changes. stuff i cant even remember.

but, DO. read my disclaimer first.

_________________
LATEST FIRMWARE(S)

BrainSlayer wrote:
we just do it since we do not like any restrictions enforced by stupid cocaine snorting managers

[x86_64] Haswell i3-4150/QCA9984/QCA9882 ------> r55797 std
[QUALCOMM] DIR-862L --------------------------------> r55797 std
▲ ACTIVE / INACTIVE ▼
[QUALCOMM] WNDR4300 v1 --------------------------> r50485 std
[BROADCOM] DIR-860L A1 ----------------------------> r50485 std


Sigh.. why do i exist anyway.. | I love you Anthony.. never forget that.. my other 99% that ill never see again..

Itsyaboy
DD-WRT User


Joined: 18 May 2016
Posts: 61

PostPosted: Tue Feb 28, 2017 8:54    Post subject: Reply with quote
eibgrad wrote:
Itsyaboy wrote:
Ok thanx I'll give echo a try next time the router needs a reboot, although the sed does add lines, but only after I manually edit the file with winscp after it's manually edited it works fine but pointless afterwards since winscp got the job done already lol
And the line added is bssid=(Mac address) the mac address of the connection I want to stay locked on to, to prevent roaming.

So do I use that as is with the quotes ? And not sure what >> is


While you can use sed to add lines, your command in particular, the way you wrote it, does nothing.

If you want to use sed to append a line to a file, you need the following.

Code:
sed -i '$a7ibssid=XX:XX:XX:XX:XX:XX' /tmp/ath0_wpa_supplicant.conf


The "$a" at the head of the string is interpreted as a command, specifically "append what ever follows to the file". Again, what you originally wrote does nothing since you didn't provided any command(s). You simply passed a string, without any commands, and expected sed to do something w/ it.

All that said, using sed to append lines to the end of a file is overkill. You can simply echo those lines using the >> operator.

Code:
echo "7ibssid=XX:XX:XX:XX:XX:XX" >> /tmp/ath0_wpa_supplicant.conf


sed is primarily used to search for text and perform certain operations upon a match (replace the text in the matched line, prepend/append a new line before/after the matched line, delete all lines after the match, etc.).


So I tried it your way but it didint work the line was not added correctly whithin network={

Bssid=
}

But at least it was adding so that's a start
Itsyaboy
DD-WRT User


Joined: 18 May 2016
Posts: 61

PostPosted: Sat Mar 04, 2017 6:49    Post subject: Reply with quote
So I finally found a way to make it work by using > to completely rewrite wpa_supplicant with that below since I couldint figure out how to add just one line whithin the network= { }bracket anyone know how that can be done ?

echo '
ap_scan=1
network={
ssid="optimumwifi"
scan_ssid=1
key_mgmt=NONE
bssid=EE:22:80:1B:CF:95
}' > /tmp/ath0_wpa_supplicant.conf
Itsyaboy
DD-WRT User


Joined: 18 May 2016
Posts: 61

PostPosted: Sat Mar 04, 2017 13:03    Post subject: Reply with quote
Ahhh k I get it thank you so much !! One last question tho how do I go about saving that command + the kill hup into a costume script or start up script @ administration commands so that I won't have to send this everytime my router reboots, do I save it just like that or do I need to do something else ?


sed -i.bak '/ssid="optimumwifi"/a 7ibssid=XX:XX:XX:XX:XX:XX' /tmp/ath0_wpa_supplicant.conf

kill -HUP "$(pidof "wpa_supplicant")"
Itsyaboy
DD-WRT User


Joined: 18 May 2016
Posts: 61

PostPosted: Sat Mar 04, 2017 14:39    Post subject: Reply with quote
Gr8!! Thanx man I really appreciate the help.
CryptoFlier
DD-WRT Novice


Joined: 20 Sep 2019
Posts: 1

PostPosted: Fri Sep 20, 2019 19:45    Post subject: Reply with quote
eibgrad wrote:
It's important in this case to make sure the wpa_supplicant process is running before attempting to reconfigure and restart it.

Place the following in your startup script.

Code:
(
set -x # uncomment/comment to enable/disable debug mode

while ! pidof wpa_suppliant > /dev/null 2>&1; do sleep 10; done; sleep 3

sed -i.bak '/ssid="optimumwifi"/a 7ibssid=XX:XX:XX:XX:XX:XX' /tmp/ath0_wpa_supplicant.conf

kill -HUP $(pidof  wpa_supplicant)
) 2>&1 | logger -t $(basename $0)[$$] &


If you have the syslog enabled, the script will dump its execution to the syslog so you can examine it, which is helpful for debugging purposes.

Code:
cat /var/log/messages | grep rc_startup


Note that there are some typos in the above script. Here is the corrected one:

Code:
(
set -x # uncomment/comment to enable/disable debug mode

while ! pidof wpa_supplicant > /dev/null 2>&1; do sleep 10; done; sleep 3

sed -i.bak '/ssid="[your ssid here]"/a\\tbssid=XX:XX:XX:XX:XX:XX' /tmp/ath0_wpa_supplicant.conf

kill -HUP $(pidof  wpa_supplicant)
) 2>&1 | logger -t $(basename $0)[$$] &
Itsyaboy
DD-WRT User


Joined: 18 May 2016
Posts: 61

PostPosted: Wed Aug 18, 2021 0:28    Post subject: Reply with quote
CryptoFlier wrote:
eibgrad wrote:
It's important in this case to make sure the wpa_supplicant process is running before attempting to reconfigure and restart it.

Place the following in your startup script.

Code:
(
set -x # uncomment/comment to enable/disable debug mode

while ! pidof wpa_suppliant > /dev/null 2>&1; do sleep 10; done; sleep 3

sed -i.bak '/ssid="optimumwifi"/a 7ibssid=XX:XX:XX:XX:XX:XX' /tmp/ath0_wpa_supplicant.conf

kill -HUP $(pidof  wpa_supplicant)
) 2>&1 | logger -t $(basename $0)[$$] &


If you have the syslog enabled, the script will dump its execution to the syslog so you can examine it, which is helpful for debugging purposes.

Code:
cat /var/log/messages | grep rc_startup


Note that there are some typos in the above script. Here is the corrected one:

Code:
(
set -x # uncomment/comment to enable/disable debug mode

while ! pidof wpa_supplicant > /dev/null 2>&1; do sleep 10; done; sleep 3

sed -i.bak '/ssid="[your ssid here]"/a\\tbssid=XX:XX:XX:XX:XX:XX' /tmp/ath0_wpa_supplicant.conf

kill -HUP $(pidof  wpa_supplicant)
) 2>&1 | logger -t $(basename $0)[$$] &


Hey, Is there anyway to add more than one bssid to the blacklist of this script? I tried using a comma then the next bssid, but doesn’t seem to work.

Edit: also last time I was here i think I had no idea that I could just add this in administration> commands> startup commands

echo
' ap_scan=1
network={
ssid="optimumwifi"
scan_ssid=1
key_mgmt=NONE
bssid_blacklist=12:20:DA:E2:F5:D6
}' > /tmp/ath1_wpa_supplicant.conf

kill -HUP "$(pidof "wpa_supplicant")"
kernel-panic69
DD-WRT Guru


Joined: 08 May 2018
Posts: 14246
Location: Texas, USA

PostPosted: Wed Aug 18, 2021 0:49    Post subject: Reply with quote
So, what exactly are we trying to do here, what is this for? MAC filtering?
_________________
"Life is but a fleeting moment, a vapor that vanishes quickly; All is vanity"
Contribute To DD-WRT
Pogo - A minimal level of ability is expected and needed...
DD-WRT Releases 2023 (PolitePol)
DD-WRT Releases 2023 (RSS Everything)

----------------------
Linux User #377467 counter.li.org / linuxcounter.net
Itsyaboy
DD-WRT User


Joined: 18 May 2016
Posts: 61

PostPosted: Wed Aug 18, 2021 1:00    Post subject: Reply with quote
kernel-panic69 wrote:
So, what exactly are we trying to do here, what is this for? MAC filtering?


Yea Mac filtering but I’m using my router as a repeater and I want it to avoid connecting to certain bssids, so I’m not filtering devices connecting to an ap, I’m filtering what the client can connect to.
Display posts from previous:    Page 1 of 1
Post new topic   Reply to topic    DD-WRT Forum Index -> Atheros WiSOC based Hardware All times are GMT

Navigation

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum