sudo virt-manager 报错的快速解决方法

$sudo virt-manager 报以下错误:

X11 connection rejected because of wrong authentication.
Traceback (most recent call last):
File "/usr/share/virt-manager/virt-manager.py", line 383, in <module>
main()
File "/usr/share/virt-manager/virt-manager.py", line 286, in main
raise gtk_error
RuntimeError: could not open display

使用 mkxauth 命令将ssh登陆的用户的 Xauthority 信息加入到 root 用户的/root/.Xauthority 文件中

$ssh -X bitbi@mybitbihost
$sudo mkxauth -m bitbi
merging /home/bitbi/.Xauthority into /root/.Xauthority ...
done
$sudo virt-manager

下面运行 sudo virt-manager 命令就正常了。

参考:1.