6 The VNC server capability provides access to the graphical console of
7 the guest VM across the network. This has a number of security
8 considerations depending on the deployment scenarios.
10 .. _vnc_005fsec_005fnone:
15 The simplest VNC server setup does not include any form of
16 authentication. For this setup it is recommended to restrict it to
17 listen on a UNIX domain socket only. For example
21 |qemu_system| [...OPTIONS...] -vnc unix:/home/joebloggs/.qemu-myvm-vnc
23 This ensures that only users on local box with read/write access to that
24 path can access the VNC server. To securely access the VNC server from a
25 remote machine, a combination of netcat+ssh can be used to provide a
28 .. _vnc_005fsec_005fpassword:
33 The VNC protocol has limited support for password based authentication.
34 Since the protocol limits passwords to 8 characters it should not be
35 considered to provide high security. The password can be fairly easily
36 brute-forced by a client making repeat connections. For this reason, a
37 VNC server using password authentication should be restricted to only
38 listen on the loopback interface or UNIX domain sockets. Password
39 authentication is not supported when operating in FIPS 140-2 compliance
40 mode as it requires the use of the DES cipher. Password authentication
41 is requested with the ``password`` option, and then once QEMU is running
42 the password is set with the monitor. Until the monitor is used to set
43 the password all clients will be rejected.
47 |qemu_system| [...OPTIONS...] -vnc :1,password=on -monitor stdio
48 (qemu) change vnc password
52 .. _vnc_005fsec_005fcertificate:
54 With x509 certificates
55 ~~~~~~~~~~~~~~~~~~~~~~
57 The QEMU VNC server also implements the VeNCrypt extension allowing use
58 of TLS for encryption of the session, and x509 certificates for
59 authentication. The use of x509 certificates is strongly recommended,
60 because TLS on its own is susceptible to man-in-the-middle attacks.
61 Basic x509 certificate support provides a secure session, but no
62 authentication. This allows any client to connect, and provides an
67 |qemu_system| [...OPTIONS...] \
68 -object tls-creds-x509,id=tls0,dir=/etc/pki/qemu,endpoint=server,verify-peer=off \
69 -vnc :1,tls-creds=tls0 -monitor stdio
71 In the above example ``/etc/pki/qemu`` should contain at least three
72 files, ``ca-cert.pem``, ``server-cert.pem`` and ``server-key.pem``.
73 Unprivileged users will want to use a private directory, for example
74 ``$HOME/.pki/qemu``. NB the ``server-key.pem`` file should be protected
75 with file mode 0600 to only be readable by the user owning it.
77 .. _vnc_005fsec_005fcertificate_005fverify:
79 With x509 certificates and client verification
80 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
82 Certificates can also provide a means to authenticate the client
83 connecting. The server will request that the client provide a
84 certificate, which it will then validate against the CA certificate.
85 This is a good choice if deploying in an environment with a private
86 internal certificate authority. It uses the same syntax as previously,
87 but with ``verify-peer`` set to ``on`` instead.
91 |qemu_system| [...OPTIONS...] \
92 -object tls-creds-x509,id=tls0,dir=/etc/pki/qemu,endpoint=server,verify-peer=on \
93 -vnc :1,tls-creds=tls0 -monitor stdio
95 .. _vnc_005fsec_005fcertificate_005fpw:
97 With x509 certificates, client verification and passwords
98 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
100 Finally, the previous method can be combined with VNC password
101 authentication to provide two layers of authentication for clients.
105 |qemu_system| [...OPTIONS...] \
106 -object tls-creds-x509,id=tls0,dir=/etc/pki/qemu,endpoint=server,verify-peer=on \
107 -vnc :1,tls-creds=tls0,password=on -monitor stdio
108 (qemu) change vnc password
112 .. _vnc_005fsec_005fsasl:
114 With SASL authentication
115 ~~~~~~~~~~~~~~~~~~~~~~~~
117 The SASL authentication method is a VNC extension, that provides an
118 easily extendable, pluggable authentication method. This allows for
119 integration with a wide range of authentication mechanisms, such as PAM,
120 GSSAPI/Kerberos, LDAP, SQL databases, one-time keys and more. The
121 strength of the authentication depends on the exact mechanism
122 configured. If the chosen mechanism also provides a SSF layer, then it
123 will encrypt the datastream as well.
125 Refer to the later docs on how to choose the exact SASL mechanism used
126 for authentication, but assuming use of one supporting SSF, then QEMU
127 can be launched with:
131 |qemu_system| [...OPTIONS...] -vnc :1,sasl=on -monitor stdio
133 .. _vnc_005fsec_005fcertificate_005fsasl:
135 With x509 certificates and SASL authentication
136 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
138 If the desired SASL authentication mechanism does not supported SSF
139 layers, then it is strongly advised to run it in combination with TLS
140 and x509 certificates. This provides securely encrypted data stream,
141 avoiding risk of compromising of the security credentials. This can be
142 enabled, by combining the 'sasl' option with the aforementioned TLS +
147 |qemu_system| [...OPTIONS...] \
148 -object tls-creds-x509,id=tls0,dir=/etc/pki/qemu,endpoint=server,verify-peer=on \
149 -vnc :1,tls-creds=tls0,sasl=on -monitor stdio
151 .. _vnc_005fsetup_005fsasl:
153 Configuring SASL mechanisms
154 ~~~~~~~~~~~~~~~~~~~~~~~~~~~
156 The following documentation assumes use of the Cyrus SASL implementation
157 on a Linux host, but the principles should apply to any other SASL
158 implementation or host. When SASL is enabled, the mechanism
159 configuration will be loaded from system default SASL service config
160 /etc/sasl2/qemu.conf. If running QEMU as an unprivileged user, an
161 environment variable SASL_CONF_PATH can be used to make it search
162 alternate locations for the service config file.
164 If the TLS option is enabled for VNC, then it will provide session
165 encryption, otherwise the SASL mechanism will have to provide
166 encryption. In the latter case the list of possible plugins that can be
167 used is drastically reduced. In fact only the GSSAPI SASL mechanism
168 provides an acceptable level of security by modern standards. Previous
169 versions of QEMU referred to the DIGEST-MD5 mechanism, however, it has
170 multiple serious flaws described in detail in RFC 6331 and thus should
171 never be used any more. The SCRAM-SHA-256 mechanism provides a simple
172 username/password auth facility similar to DIGEST-MD5, but does not
173 support session encryption, so can only be used in combination with TLS.
175 When not using TLS the recommended configuration is
180 keytab: /etc/qemu/krb5.tab
182 This says to use the 'GSSAPI' mechanism with the Kerberos v5 protocol,
183 with the server principal stored in /etc/qemu/krb5.tab. For this to work
184 the administrator of your KDC must generate a Kerberos principal for the
185 server, with a name of 'qemu/somehost.example.com@EXAMPLE.COM' replacing
186 'somehost.example.com' with the fully qualified host name of the machine
187 running QEMU, and 'EXAMPLE.COM' with the Kerberos Realm.
189 When using TLS, if username+password authentication is desired, then a
190 reasonable configuration is
194 mech_list: scram-sha-256
195 sasldb_path: /etc/qemu/passwd.db
197 The ``saslpasswd2`` program can be used to populate the ``passwd.db``
198 file with accounts. Note that the ``passwd.db`` file stores passwords
201 Other SASL configurations will be left as an exercise for the reader.
202 Note that all mechanisms, except GSSAPI, should be combined with use of
203 TLS to ensure a secure data channel.