After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 752173 - nmcli: can't connect to hidden networks
nmcli: can't connect to hidden networks
Status: RESOLVED FIXED
Product: NetworkManager
Classification: Platform
Component: Wi-Fi
unspecified
Other Linux
: Normal normal
: ---
Assigned To: NetworkManager maintainer(s)
NetworkManager maintainer(s)
Depends on:
Blocks:
 
 
Reported: 2015-07-09 14:15 UTC by Dan Williams
Modified: 2015-08-14 18:52 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Dan Williams 2015-07-09 14:15:12 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.
Comment 1 Jiri Klimes 2015-07-10 12:14:36 UTC
Implemented in branch jk/nmcli-hidden-ssid-bgo752173.

If you could test it, that would be great. I didn't test it much myself.
Comment 2 Dan Williams 2015-07-12 00:58:17 UTC
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?
Comment 3 Jiri Klimes 2015-07-14 09:01:47 UTC
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.
Comment 4 Beniamino Galvani 2015-07-14 12:53:41 UTC
Works fine here to connect to a hidden SSID with WPA.
Comment 5 Thomas Haller 2015-07-17 11:55:12 UTC
>> 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.
Comment 6 Dan Williams 2015-07-17 23:27:37 UTC
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.
Comment 7 Jiri Klimes 2015-08-12 15:17:37 UTC
(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.
Comment 8 Thomas Haller 2015-08-13 13:06:56 UTC
(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
Comment 9 Jiri Klimes 2015-08-14 18:52:20 UTC
(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