1

I have Wi-Fi enabled but would prefer to paste in my Wi-Fi password rather than type it because it is very long. Can this be done and can I encrypt the password? I am running a dual boot and LibreELEC is on one partition, which is where I need the wi-fi enabled.

2

Note that if you want to keep your WiFi password encrypted (perhaps with a shorter password), the piece of software you're looking for is a password manager. The most basic one I know about is pass, but there are many more.

Typically a password manager can copy a password to the clipboard (if you're using X), or pipe it to a standard output, so you can use it as a part of the command line or script:

command -p `pass WIFI/MyNetwork`  # runs "command -p MyPassword"
pass WIFI/MyNetwork | command     # runs "command" and types "MyPassword" in the prompt
1

You have two question.

  1. The password is in the file wpa_supplicant.conf. You can either write the complete configuration yourself or create an entry with the GUI with a dummy password and then edit the file. An entry in the configuration file looks like this example from the man page:

      network={
           ssid="home"
           scan_ssid=1
           key_mgmt=WPA-PSK
           psk="very secret passphrase"
      }
    
  2. You can't effectively encrypt the password if you want it to be usable, because the wpa_supplicant needs the password unencrypted. If you save the password encrypted, you also need the encryption key somewhere, and that makes the encryption useless.

    You could theoretically encrypt the password with a ky that is shorter and easier to type, but you would have to enter the key each time the password must be decrypted, and as far as I know there is no support for that, you would have to write your own scripts.

1

As outlined elsewhere the WiFi connection is normally controlled by the contents of the wpa_supplicant.conf file, this is where your SSIDs and passwords are stored and you can indeed edit this file by hand to add your password. Note that the password on the psk line must be either be the 256-bit pre-shared key (PSK) or as plaintext (from which wpa_supplicant will then generate the PSK) so there's no way to further "encrypt" the password and still have it work seamlessly, it will end up in the file where you can look at it and copy it.

There's a command called wpa_passphrase that will generate the required network{...} stanza with 256-bit PSK for you to add to your wpa_supplicant.conf file. You can even pipe the output directly into the file.

For example:

$ wpa_passphrase MySSID MySuperLongAndSecurePasswordPhraseThatICopiedFromElsewhere

network={
        ssid="MySSID"
        #psk="MySuperLongAndSecurePasswordPhraseThatICopiedFromElsewhere"
        psk=2b16917b85eb87cdd2ad5323113fdd0f9112f2c5d271bd541b555d4b818b330f
}

or

$ sudo wpa_passphrase MySSID MySuperLongAndSecurePasswordPhraseThatICopiedFromElsewhere >> /etc/wpa_supplicant/wpa_supplicant.conf

As you can see the command combines the given password with the SSID for the PSK output but also stores the password in plaintext as well (but commented out with the # at the start). Once you've confirmed that it's working you can delete that line from the file. I believe that the file is read-protected on Raspbian but with a password-less sudo it's not really that much more secure.

  • 1
    Note that while this method does obfuscates the plaintext password, it doesn't prevent it from being stolen. Anyone who is able to read wpa_supplicant.conf will be able to connect to the WiFi in both cases. – Dmitry Grigoryev Jul 24 at 8:48
  • 2
    @DmitryGrigoryev Absolutely agree, my intention was to answer the first part of the question about entering (or pasting) the password on the terminal, not to imply that the password is somehow encrypted by the wpa_passphrase command. I'll edit to make this clearer. – Roger Jones Jul 24 at 9:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.