在 802.1x 企业网络中,我可以使用 NetworkManager 配置 802.1x 参数,包括密码。这一切都可行,但需要以明文形式存储密码。
我们正在尝试使用 Netplan 更安全地存储凭据(作为散列密码),但我们无法使 802.1x 连接进行身份验证。
我还没有找到一个好的指南来构建包含 802.1x 凭据的 Netplan 配置。
(更新:Netplan 中有一个关于散列密码的错误,https://github.com/CanonicalLtd/netplan/pull/78),这似乎是主要问题)
这是一个不起作用的文件
network:
version: 2
renderer: networkd
ethernets:
enp0s31f6:
auth:
key-management: 802.1x
password: hash:some-stuff-here
method: peap
identity: ghewett
dhcp4: false
addresses:
- 1.2.3.4
gateway4: 5.6.7.8
nameservers:
search: [cisco.com, otherdomain]
addresses:
- 1.1.1.1
- 2.2.2.2
(IP 和凭证已更改)
这给了我们
DEBUG:command generate: running ['/lib/netplan/generate']
** (generate:19354): DEBUG: 09:23:41.614: Processing input file /etc/netplan/01-netcfg.yaml..
** (generate:19354): DEBUG: 09:23:41.614: starting new processing pass
Error in network definition /etc/netplan/01-netcfg.yaml line 7 column 6: unknown key auth
答案1
看https://netplan.io/examples,以及https://netplan.io该网站总体上提供了很好的信息。确保sudo netplan --debug generate
检查 .yaml 文件,并生成配置文件,然后sudo netplan apply
激活它们。
Authentication
Netplan supports advanced authentication settings for ethernet and wifi interfaces, as well as individual wifi networks, by means of the auth block.
auth (mapping)
Specifies authentication settings for a device of type ethernets:, or an access-points: entry on a wifis: device.
The auth block supports the following properties:
key-management (scalar)
The supported key management modes are none (no key management); psk (WPA with pre-shared key, common for home wifi); eap (WPA with EAP, common for enterprise wifi); and 802.1x (used primarily for wired Ethernet connections).
password (scalar)
The password string for EAP, or the pre-shared key for WPA-PSK.
The following properties can be used if key-management is eap or 802.1x:
method (scalar)
The EAP method to use. The supported EAP methods are tls (TLS), peap (Protected EAP), and ttls (Tunneled TLS).
identity (scalar)
The identity to use for EAP.
anonymous-identity (scalar)
The identity to pass over the unencrypted channel if the chosen EAP method supports passing a different tunnelled identity.
ca-certificate (scalar)
Path to a file with one or more trusted certificate authority (CA) certificates.
client-certificate (scalar)
Path to a file containing the certificate to be used by the client during authentication.
client-key (scalar)
Path to a file containing the private key corresponding to client-certificate.
client-key-password (scalar)
Password to use to decrypt the private key specified in client-key if it is encrypted.
来源:https://netplan.io/reference#authentication
更新#1:
注意:确保您的.yaml 文件中没有 TABS...
添加您的证书,恢复 IP,然后尝试这个...
network:
version: 2
renderer: networkd
ethernets:
enp0s31f6:
auth:
key-management: 802.1x
method: peap
identity: "[email protected]"
ca-certificate: my_ca.pem
client-certificate: my_cert.pem
client-key: my_key.pem
addresses:
- 1.2.3.4
gateway4: 5.6.7.8
nameservers:
search: [cisco.com, otherdomain]
addresses:
- 1.1.1.1
- 2.2.2.2
答案2
Ubuntu 18.04.02 附带的默认 netplan 不支持有线身份验证,因此无法正常工作。2019 年 3 月初在 github 上发布的最新版本确实支持身份验证,但缺少其他必需的东西。WPA 请求者需要 CLI 标志才能使用有线驱动程序,我写了一个 PR 将其添加到 netplan。Netplan 还以破坏它们的方式处理散列密码,因此还有另一个 PR 来解决这个问题。
如果您想尝试这些,PR,说明如下:
有一个安装有 Ubuntu 18.04.02 的服务器
安装请求者
- sudo apt 安装 wpasupplicant”
安装所需的构建工具
- sudo apt install make cpp pkg-config libyaml-dev uuid-dev libgio2.0-cil-dev libglib2.0-dev pandoc
获取已修补的 netplan 软件
- git 克隆https://github.com/fluffy/netplan.git
- cd 网络计划
- git 全部签出
使用以下方式构建并安装
- 制作
- 安装
生成密码的哈希版本
- echo -n'我的密码'|iconv-t UTF-16LE|openssl md4-binary|xxd-p
- 历史-c
编辑 netplan 配置文件
- cd /etc/netplan
- sudo mv 50-cloud-init.yaml config.yaml
- sudo emacs /etc/netplan/config.yaml
让它看起来像这样:
network:
version: 2
ethernets:
enp0s31f6:
dhcp4: true
optional: true
auth:
key-management: 802.1x
wired: true
method: ttls
identity: [email protected]
password: hash:83...11
适用于
- sudo netplan 申请
此时,如果您重新启动,它应该可以工作,但需要检查一些事项以帮助调试
检查 WPA 请求方配置文件
- sudo cat /run/netplan/wpa-enp0s31f6.conf
它看起来应该像
ctrl_interface=/run/wpa_supplicant
network={
key_mgmt=IEEE8021X
eap=TTLS
identity="[email protected]"
password=hash:83..11
}
如果使用散列密码,请确保密码周围没有引号。
检查 systemd 模板
- ls /run/systemd/system/systemd-networkd.service.wants/netplan*enp0s31f6.service
它应该返回类似
/运行/systemd/system/systemd-networkd.service.wants/[电子邮件保护]
关键是检查它是否为 wpa-wired
测试身份验证是否可以使用密码和所有
终止任何正在运行的 wpa_supplicant 版本,然后执行
sudo wpa_supplicant -c /run/netplan/wpa-enp0s31f6.conf -i enp0s31f6 -D 有线
您将看到有关 802.1x 消息的信息流,并且在末尾应该会出现“身份验证成功”
您需要按 Ctrl^C 来将其杀死。
- 重新启动并享受....