Linux更改machine-ID

systemd-machine-id-setup可以重新生成machine ID。

如果DBUS machine ID存在的话,会直接将其拷贝过来,所以可以先更新DBUS machine ID:

sudo bash -c "dbus-uuidgen > /var/lib/dbus/machine-id"
sudo rm /etc/machine-id
sudo systemd-machine-id-setup
Initializing machine ID from D-Bus machine ID.

参考: https://www.linuxquestions.org/questions/slackware-14/security-implications-of-var-lib-dbus-machine-id-thoughts-4175665203/

也可以把/var/lib/dbus/machine-id/etc/machine-id一起删除,再用systemd-machine-id-setup重新生成/etc/machine-id,然后再创建一个符号链接:

sudo rm /var/lib/dbus/machine-id /etc/machine-id
sudo systemd-machine-id-setup
sudo ln -s /etc/machine-id /var/lib/dbus/machine-id

ArchLinux的/var/lib/dbus/machine-id默认就是一个指向/etc/machine-id的符号链接。

参考:

Linux7重新生成Machine-ID

https://wiki.debian.org/MachineId

posted @ 2024-09-28 13:07  寻找繁星  阅读(69)  评论(0编辑  收藏  举报