13.2. 使用 TLS 和 SSL 进行远程管理

You can manage virtual machines using TLS and SSL. TLS and SSL provides greater scalability but is more complicated than ssh (refer to 第 13.1 节 “使用 SSL 进行远程管理”). TLS and SSL is the same technology used by web browsers for secure connections. The libvirt management connection opens a TCP port for incoming connections, which is securely encrypted and authenticated based on x509 certificates. In addition the VNC console for each guest virtual machine will be setup to use TLS with x509 certificate authentication.

这个方法不需要在要进行管理的远程机器中有 shell 帐户,但需要为访问管理服务或者 VNC 控制台设定额外的防火墙规则。证书取消列表可用来取消对用户的访问。

为 virt-manager 设定 TLS/SSL 访问的步骤

以下简短指南假定您从头开始设置,而且您没有任何 TLS/SSL 证书知识背景。如果您刚好有证书管理服务器,那么您可以跳过第一步。

libvirt 服务器设定

有关生成证书的详情请参考 libvirt 网页 http://libvirt.org/remote.html

Xen VNC 服务器

Xen VNC 服务器可以通过编辑配置文件 /etc/xen/xend-config.sxp 启用 TLS。删除配置文件 (vnc-tls 1) 配置参数前的注释标记。

The /etc/xen/vnc directory needs the following 3 files:

  • ca-cert.pem - The CA certificate

  • server-cert.pem - The Server certificate signed by the CA

  • server-key.pem - The server private key

This provides encryption of the data channel. It might be appropriate to require that clients present their own x509 certificate as a form of authentication. To enable this remove the commenting on the (vnc-x509-verify 1) parameter.

virt-managervirsh 客户端设定

此时的客户端设定有一些不同。要通过 TLS 启用 libvirt 管理 API,就必须将 CA 以及客户端证书放在 /etc/pki。有关详情请参考 http://libvirt.org/remote.html

virt-manager 用户界面,连接到主机时请使用 ‘SSL/TLS‘ 传送机制。

virsh 中 URL 有以下格式:

  • 在 KVM 中使用 qemu://hostname.guestname/system

  • 在 Xen 中使用 xen://hostname.guestname/

要为 VNC 启用 SSL 和 TLS,需要您将证书验证以及客户端证书放在 $HOME/.pki 中,即以下三个文件:

  • CA 或者 ca-cert.pem - CA 证书。

  • libvirt-vnc 或者 clientcert.pem - CA 签注的客户端证书。

  • libvirt-vnc 或者 clientkey.pem - 客户端私钥。