我尝试直接在网络TEST-EAP-TLS下面的路径上创建
/etc/NetworkManager/system-connections/TEST-EAP-TLS
文件
[connection]
id=TEST-EAP-TLS
type=wifi
permissions=user:$current_user:;
[wifi]
mac-address=$mac
mode=infrastructure
ssid=TEST-EAP-TLS
[wifi-security]
key-mgmt=wpa-eap
[802-1x]
ca_cert=$cert_path_out/$cert_name.pem
client_cert=$cert_path_out/$cert_name.crt
eap=tls;
identity=${USERNAME}
private_key=$cert_path_out/$cert_name.p12
private_key_passwd=${PASSWD}
但是需要点击网络进行连接。
我需要启用/注册更多功能吗?
已更新
我能够使用bash脚本中的python脚本解决问题。见下文。
据我了解,我需要在网络管理器中处理一些dbus条目,因此,我不得不寻找这种选择。
#- * -coding: utf - 8 - * -
import dbus
import uuid
def path_to_value(path):
return dbus.ByteArray("file://" + path + "\0")
s_con = dbus.Dictionary({
'type': '802-11-wireless',
'uuid': str(uuid.uuid4()),
'permissions': ['user:$current_user'],
'id': 'TEST-EAP-TLS'
})
s_wifi = dbus.Dictionary({
'ssid': dbus.ByteArray("TEST-EAP-TLS"),
'mode': 'infrastructure'
})
s_wsec = dbus.Dictionary({
'key-mgmt': 'wpa-eap'
})
s_8021x = dbus.Dictionary({
'eap': ['tls'],
'identity': '$USERNAME',
'client-cert': path_to_value("$cert_path_out/$cert_name.crt"),
'ca-cert': path_to_value("$cert_path_out/$cert_name.pem"),
'private-key': path_to_value("$cert_path_out/$cert_name.p12"),
'private-key-password': '$PASSWD'
})
s_ip4 = dbus.Dictionary({
'method': 'auto'
})
s_ip6 = dbus.Dictionary({
'method': 'ignore'
})
con = dbus.Dictionary({
'connection': s_con,
'802-11-wireless': s_wifi,
'802-11-wireless-security': s_wsec,
'802-1x': s_8021x,
'ipv4': s_ip4,
'ipv6': s_ip6
})
bus = dbus.SystemBus()
proxy = bus.get_object("org.freedesktop.NetworkManager", "/org/freedesktop/NetworkManager/Settings")
settings = dbus.Interface(proxy, "org.freedesktop.NetworkManager.Settings")
settings.AddConnection(con)