Commit 3c9b8671 authored by Jiří Klimeš's avatar Jiří Klimeš

cli: add 'passwd-file' option for 'nmcli connection up' to provide passwords

It is useful for running nmcli without --ask option, i.e. non-interactively.

Example contents of the file:
wifi.psk: s e c r e t 12345
802-1x.password:kili manjaro
parent de7f85bd
This diff is collapsed.
......@@ -502,7 +502,8 @@ _nmcli_compl_ARGS()
user| \
username| \
service| \
password| \
if [[ "${#words[@]}" -eq 2 ]]; then
return 0
......@@ -845,9 +846,9 @@ _nmcli()
_nmcli_compl_ARGS_CONNECTION && return 0
if [[ "$COMMAND_CONNECTION_TYPE" = "ifname" ]]; then
OPTIONS=(ap nsp)
OPTIONS=(ap nsp passwd-file)
OPTIONS=(ifname ap nsp)
OPTIONS=(ifname ap nsp passwd-file)
......@@ -499,7 +499,9 @@ nmc_init (NmCli *nmc)
nmc->timeout = -1;
nmc->connections = NULL;
nmc->secret_agent = NULL;
nmc->pwds_hash = NULL;
nmc->should_wait = FALSE;
nmc->nowait_flag = TRUE;
......@@ -531,6 +533,8 @@ nmc_cleanup (NmCli *nmc)
nm_secret_agent_unregister (nmc->secret_agent, NULL, NULL);
g_object_unref (nmc->secret_agent);
if (nmc->pwds_hash)
g_hash_table_destroy (nmc->pwds_hash);
g_free (nmc->required_fields);
nmc_empty_output_fields (nmc);
......@@ -111,7 +111,9 @@ typedef struct _NmCli {
int timeout; /* Operation timeout */
const GPtrArray *connections; /* List of connections */
NMSecretAgent *secret_agent; /* Secret agent */
GHashTable *pwds_hash; /* Hash table with passwords in passwd-file */
gboolean should_wait; /* Indication that nmcli should not end yet */
gboolean nowait_flag; /* '--nowait' option; used for passing to callbacks */
......@@ -327,10 +327,10 @@ When no command is given to the \fIconnection\fP object, the default action
is 'nmcli connection show'.
.B up [ id | uuid | path ] <ID> [ifname <ifname>] [ap <BSSID>] [nsp <name>]
.B up [ id | uuid | path ] <ID> [ifname <ifname>] [ap <BSSID>] [nsp <name>] [passwd <file with passwords>]
.B up ifname <ifname> [ap <BSSID>] [nsp <name>]
.B up ifname <ifname> [ap <BSSID>] [nsp <name>] [passwd <file with passwords>]
Activate a connection. The connection is identified by its name, UUID or D-Bus
......@@ -355,6 +355,23 @@ Available options are:
\(en BSSID of the AP which the command should connect to (for Wi\(hyFi connections)
.IP \fInsp\fP 13
\(en NSP (Network Service Provider) which the command should connect to (for WiMAX connections)
.IP \fIpasswd-file\fP 13
\(en some networks may require credentials during activation. You can give these
credentials using this option.
Each line of the file should contain one password in the form of
\fBsetting_name.property_name:the password\fP
For example, for WPA Wi-Fi with PSK, the line would be
For 802.1X password, the line would be
\fI802-1x.password:my 1X password\fP
nmcli also accepts "wifi-sec" and "wifi" strings instead of "802-11-wireless-security".
When a required password is not given, nmcli will ask for it when run with --ask.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment