RetroPie forum home
    • Recent
    • Tags
    • Popular
    • Home
    • Docs
    • Register
    • Login

    [SOLVED][Feature Request]Wifi Key import via /boot/wifikeyfile.txt

    Scheduled Pinned Locked Moved Ideas and Development
    wifi configwifiimprovementskey import
    26 Posts 9 Posters 48.1k Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • cyperghostC
      cyperghost
      last edited by cyperghost

      I solved the issue. We can import any WIFI and SSID that is setted to file /boot/wifikeyfile.txt

      An example forwifikeyfile.txt is:

      ssid="WIFI BASE SSID"
      psk="Secret Key"
      

      This will result to etc/wpa_supplicant/wpa_supplicant.conf
      You see annother WIFI setting is just placed under your current settings.
      So easily new configs can be imported and appended to WIFI setup.

      ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
      update_config=1
      # RETROPIE CONFIG START
      network={
      	ssid="RealNetwork1"
      	psk="RealKey1"
      }
      # RETROPIE CONFIG END
      network={
      	ssid="WIFI BASE SSID"
      	#psk="Secret Key"
      	psk=5bee4223648102a29c09b2b52bbd2fc920c4d90ced9292781477d1bf219b753a
      }
      

      All this is done by this small Bashfile Wifikeyimport.sh

      #!/bin/bash
      # Wifikeyimporter by cyperghost
      # For RetroPie - greetz fly out to Vika, BuZz, Cott, meleu
      
      # Path to Wifi keyfile
      wifikeyfile="/boot/wifikeyfile.txt"
      
      # Sample wifikeyfile.txt ... place it to /boot/wifikeyfile.txt
      # psk="Your WIFI password"
      # ssid="WIFI SSID"
      
      . $wifikeyfile
      
      echo "Wifi SSID in wifikeyfile is named: " $ssid
      echo "Setted Password is: "$psk
      
      sudo -i|wpa_passphrase "$ssid" "$psk" >> /etc/wpa_supplicant/wpa_supplicant.conf & exit
      

      All we need is to locate the bash file posted above into RetroPiemenu! So we need NO keyboard to import setted wifi keys.

      For further information read here

      Knowledge is power :)
      This is my first batch file for unix systems - so excuse me for noobish errors
      It works for my current setup and login for user Pi ... can someone please verify?

      Important: Make wifikeyimport.sh executeable, then login as pi and use SUDO command. Two ways

      1. sudo ./wifikeyimport.sh
      2. sudo bash wifikeyimport.sh
      1 Reply Last reply Reply Quote 4
      • BuZzB
        BuZz administrators
        last edited by

        I will add the facility to use this configuration file from the wifi module. Cheers.

        To help us help you - please make sure you read the sticky topics before posting - https://retropie.org.uk/forum/topic/3/read-this-first

        cyperghostC 1 Reply Last reply Reply Quote 2
        • cyperghostC
          cyperghost @BuZz
          last edited by

          @BuZz That would be nice!

          BuZzB 1 Reply Last reply Reply Quote 0
          • BuZzB
            BuZz administrators @cyperghost
            last edited by BuZz

            @cyperghost implemented. Went with your naming convention.

            https://github.com/RetroPie/RetroPie-Setup/commit/d745cebe823820d115afa01e2359dcd6005ce443

            To help us help you - please make sure you read the sticky topics before posting - https://retropie.org.uk/forum/topic/3/read-this-first

            cyperghostC 2 Replies Last reply Reply Quote 3
            • cyperghostC
              cyperghost @BuZz
              last edited by cyperghost

              @BuZz
              That's a nice one! Works 100%

              Test area:
              I connected via Wifi SSH to Raspberry.
              Imported wrong (default sample keyfile) >> Lost connection

              Powered Off Raspberry, removed SD card, inserted in Windows mashine
              Opend wifikeyfile.txt from FAT32 partition via editor (Notepad ++ is the better choice!)
              Changed default entries to correct password.

              Back to Raspberry, RetroPie Menu, Select Wifi
              Imported now right setted keyfile >> Connections established!

              Thank you so much! It was never so easy ;)
              All without keyboard :)

              I see my noob-code-style is totally converted to professional-style :)

              1 Reply Last reply Reply Quote 2
              • cyperghostC
                cyperghost @BuZz
                last edited by cyperghost

                @BuZz
                One question to your latest coding...

                 if [[ -f "/boot/wifikeyfile.txt" ]]; then
                                        iniConfig " = " "\"" "/boot/wifikeyfile.txt"
                                        iniGet "ssid"
                                        local ssid="$ini_value"
                                        iniGet "psk"
                                        local psk="$ini_value"
                                        create_config_wifi "wpa" "$ssid" "$psk"
                                        gui_connect_wifi
                                 else
                

                The line create_config_wifi "wpa" "$ssid" "$psk" is to create a WPA network. Do you think it makes sense to add a third key to wifikeyfile.txt that sets the encryption? If the value is empty then WPA can be set as default. What do you think?

                I think 99% of all WIFI networks work with WPA so it isn't a important feature.

                1 Reply Last reply Reply Quote 0
                • BuZzB
                  BuZz administrators
                  last edited by

                  Sorry for late reply - must have missed this.

                  we could but as you say - does anyone use wep etc now ? It would be an easy change though so I'll make a note.

                  To help us help you - please make sure you read the sticky topics before posting - https://retropie.org.uk/forum/topic/3/read-this-first

                  1 Reply Last reply Reply Quote 1
                  • RetroProgrammingR
                    RetroProgramming
                    last edited by

                    I know this one is marked as [SOLVED] but I have an issue with this function.

                    I tried it with image 4.1.
                    I created the wifikeyfile.txt with the standard Windows Notepad.
                    Windows seperates lines by 0x0D 0x0A. This causes a problem.

                    After importing the file the 0x0D is still attached to the ssid + psk and the connection fails.
                    0_1479035280720_RetroPieV41-problem.png

                    I guess there are a lot auf Windows-Users and perhaps it is possible to remove the 0x0D to solve this issue.

                    herb_fargusH 1 Reply Last reply Reply Quote 0
                    • herb_fargusH
                      herb_fargus administrators @RetroProgramming
                      last edited by

                      @RetroProgramming use notepad++ with Unix line endings

                      If you read the documentation it will answer 99% of your questions: https://retropie.org.uk/docs/

                      Also if you want a solution to your problems read this first: https://retropie.org.uk/forum/topic/3/read-this-first

                      1 Reply Last reply Reply Quote 0
                      • RetroProgrammingR
                        RetroProgramming
                        last edited by

                        I know what to do, but do you really want to tell every avarage Windows-User to install an extra tool to edit this tiny file?

                        1 Reply Last reply Reply Quote 0
                        • BuZzB
                          BuZz administrators
                          last edited by

                          I will sort it.

                          To help us help you - please make sure you read the sticky topics before posting - https://retropie.org.uk/forum/topic/3/read-this-first

                          1 Reply Last reply Reply Quote 0
                          • BuZzB
                            BuZz administrators
                            last edited by

                            Should handle CRLF files now.

                            To help us help you - please make sure you read the sticky topics before posting - https://retropie.org.uk/forum/topic/3/read-this-first

                            RetroProgrammingR 1 Reply Last reply Reply Quote 2
                            • D
                              DP
                              last edited by

                              Thanks for adding this great feature so we can configure wifi networks without a keyboard! At the moment you can only connect to one wifi network with the script, would it possible to reprogram it to define a number of wifi networks to choose from? I would like this feature as sometimes I want to take my retropie to a friend's house or use the wifi hotspot on my phone and this would save bringing a keyboard along.

                              Thanks again,
                              DP

                              1 Reply Last reply Reply Quote 0
                              • BuZzB
                                BuZz administrators
                                last edited by BuZz

                                @DP That is beyond the scope of what I think would be useful for most people vs effort to implement. If you want to preconfigure your system for multiple wifi networks you can do so manually by editing /etc/wpa_supplicant/wpa_supplicant.conf and add some additional network blocks.

                                To help us help you - please make sure you read the sticky topics before posting - https://retropie.org.uk/forum/topic/3/read-this-first

                                1 Reply Last reply Reply Quote 0
                                • D
                                  DP
                                  last edited by

                                  @BuZz That's fair enough. Thanks for the suggestion, I was able to pre-configure my wifi networks manually although I had to set update_config=0 otherwise the file would get overwritten. It seems like a bit of an oversight that when switching networks it always asks for a psk even if it already provided within wpa_supplicant.conf but it works for my purposes now so I'm happy!

                                  Thanks for your help!

                                  cyperghostC 1 Reply Last reply Reply Quote 0
                                  • cyperghostC
                                    cyperghost @DP
                                    last edited by cyperghost

                                    @DP Sorry for being late .... you can modify the bash file I've created in first posting.
                                    This will append wifi settings to wpa_supplicant. The PW will also be hashed btw...

                                    The solution @BuZz created is a fine (to be true finest) way to connect to network. After network is established you can do anything you want.... for example create a bash file by yourself to add more networks and just put it in ES config menu :)

                                    1 Reply Last reply Reply Quote 0
                                    • RetroProgrammingR
                                      RetroProgramming @BuZz
                                      last edited by

                                      @BuZz said in [SOLVED][Feature Request]Wifi Key import via /boot/wifikeyfile.txt:

                                      Should handle CRLF files now.

                                      Thanks, looks good now.

                                      1 Reply Last reply Reply Quote 0
                                      • cyperghostC
                                        cyperghost
                                        last edited by

                                        For info:
                                        you can use this side to create hashed keys
                                        https://www.wireshark.org/tools/wpa-psk.html

                                        Just enter SSID and PW and it will generate hashed key.
                                        Knowledge is power!

                                        1 Reply Last reply Reply Quote 0
                                        • J
                                          jseibert81
                                          last edited by

                                          Guys. There is no obvious explanation as to how or where to put this file. I see the scripts an that is it. I am not able to use the pi finder utility. I am trying to manually add the wifikeyfile.txt. How?

                                          herb_fargusH 1 Reply Last reply Reply Quote 0
                                          • herb_fargusH
                                            herb_fargus administrators @jseibert81
                                            last edited by

                                            @jseibert81 sure there is. Right in the docs:

                                            https://retropie.org.uk/docs/Wifi/#connecting-to-wifi-without-a-keyboard

                                            If you read the documentation it will answer 99% of your questions: https://retropie.org.uk/docs/

                                            Also if you want a solution to your problems read this first: https://retropie.org.uk/forum/topic/3/read-this-first

                                            J 1 Reply Last reply Reply Quote 1
                                            • First post
                                              Last post

                                            Contributions to the project are always appreciated, so if you would like to support us with a donation you can do so here.

                                            Hosting provided by Mythic-Beasts. See the Hosting Information page for more information.