GNOME Bugzilla – Bug 752173
nmcli: can't connect to hidden networks
Last modified: 2015-08-14 18:52:20 UTC
$ sudo nmcli dev wifi con '<SSID>' password '<Password>' name 'hidden AP' Error: No network with SSID '<SSID>' found. nmcli looks for the AP in the scan list before creating the connection; if the AP is hiding the SSID, this obviously won't work the first time you connect to that AP. I suppose we should add a "--hidden" option to dev wifi connect that sets wireless.hidden=true, and if the AP list check fails, goes ahead and tries to connect anyway.
Implemented in branch jk/nmcli-hidden-ssid-bgo752173. If you could test it, that would be great. I didn't test it much myself.
Branch looks good, but I thought of another complication :( When the SSID is hidden and security is used, the AP flags still have to be compatible with the final AP that gets found in the scan list. So we'd have to have some way for the user to indicate whether the passphrase is WEP or WPA. One thought would be to change the 'wep-key-type' argument to 'key-type' with values like wep-key or wep-passphrase or wpa-psk (and keep wep-key-type for backwards compat), and then when hidden=TRUE use the key-type to set the AP flags correctly? A different approach might be to use the RequestScan() function... we actually make use of the dict argument and add an "ssids" item of type 'aay' (array of byte arrays), and then when the user requests a connection to the hidden SSID, we ask NM to probe-scan that SSID. Then when NM has scanned, nmcli does the existing codepath to find the SSID in the scan list and grab the AP flags and connect as normal (and still set the 'hidden' property to TRUE). This approach would mean we don't need to add more command-line args... I'm not sure which way seems better, thoughts?
I prefer the second approach because it doesn't clutter the command line and the options in RequestScan() might be useful elsewhere too. Repushed the branch with option 2 implementation.
Works fine here to connect to a hidden SSID with WPA.
>> cli: add 'ssids' parameter for 'nmcli device wifi rescan' this gives no possibility to escape the separators. I think that is bad, spaces in an SSID are not uncommon. Maybe we need a more sophisticated way with escaping, or better: can we support multiple "ssid" arguments instead where each argument only specifies one SSID? Repeated fields is a new paradigm, so it needs more work with bash-completion to get it right. But the upside is, we can then complete with the available SSIDs. Also, as is, bash completion is not correct because "ssids" is unknown to _nmcli_compl_ARGS(). Pushed fixup commits.
LGTM with Thomas' fixups. I'm ok with scanning only one SSID for now, as long as we can support more fairly easily in the future.
(In reply to Thomas Haller from comment #5) > >> cli: add 'ssids' parameter for 'nmcli device wifi rescan' > > this gives no possibility to escape the separators. I think that is bad, > spaces in an SSID are not uncommon. > > Maybe we need a more sophisticated way with escaping, or better: can we > support multiple "ssid" arguments instead where each argument only specifies > one SSID? > Added support for multiple 'ssid' parameters. > Repeated fields is a new paradigm, so it needs more work with > bash-completion to get it right. But the upside is, we can then complete > with the available SSIDs. > I didn't look into this, but that we can enhance the bash completion later. > > Pushed fixup commits. Squashed the commits, rebased to master and updated core bits for GDBus migration.
(In reply to Jiri Klimes from comment #7) > (In reply to Thomas Haller from comment #5) > > Repeated fields is a new paradigm, so it needs more work with > > bash-completion to get it right. But the upside is, we can then complete > > with the available SSIDs. > > > I didn't look into this, but that we can enhance the bash completion later. later is now :) Pushed a fixup for that. The rest LGTM
(In reply to Thomas Haller from comment #8) > (In reply to Jiri Klimes from comment #7) > > (In reply to Thomas Haller from comment #5) > > > Repeated fields is a new paradigm, so it needs more work with > > > bash-completion to get it right. But the upside is, we can then complete > > > with the available SSIDs. > > > > > I didn't look into this, but that we can enhance the bash completion later. > > later is now :) > Pushed a fixup for that. > Thanks, merged :) master: 32c34a8 merge: 'ssids' RequestScan() option, nmcli connecting hidden SSID (rh #752173) 5955a66 cli: fix connecting to a hidden SSID with 'nmcli dev wifi connect' (bgo #752173) e247567 cli: add 'ssid' parameter for 'nmcli device wifi rescan' 7691fe5 libnm: add new functions allowing passing options to RequestScan() D-Bus call 87b2d78 core: accept 'ssids':aay option in RequestScan() dictionary parameter Backport to nm-1-0: 7f3115e merge: 'ssids' RequestScan() option, nmcli connecting hidden SSID (rh #752173) e0762f4 cli: fix connecting to a hidden SSID with 'nmcli dev wifi connect' (bgo #752173) b1f62ce cli: add 'ssid' parameter for 'nmcli device wifi rescan' 91c0555 libnm: add new functions allowing passing options to RequestScan() D-Bus call 7706b99 core: accept 'ssids':aay option in RequestScan() dictionary parameter