docs: Stop building qemu-doc
[qemu/ar7.git] / docs / system / vnc-security.texi
blobabf7f7fa43aa8a2bafb44f337e16d69c57f89497
1 @node vnc_security
2 @section VNC security
4 The VNC server capability provides access to the graphical console
5 of the guest VM across the network. This has a number of security
6 considerations depending on the deployment scenarios.
8 @menu
9 * vnc_sec_none::
10 * vnc_sec_password::
11 * vnc_sec_certificate::
12 * vnc_sec_certificate_verify::
13 * vnc_sec_certificate_pw::
14 * vnc_sec_sasl::
15 * vnc_sec_certificate_sasl::
16 * vnc_setup_sasl::
17 @end menu
18 @node vnc_sec_none
19 @subsection Without passwords
21 The simplest VNC server setup does not include any form of authentication.
22 For this setup it is recommended to restrict it to listen on a UNIX domain
23 socket only. For example
25 @example
26 @value{qemu_system} [...OPTIONS...] -vnc unix:/home/joebloggs/.qemu-myvm-vnc
27 @end example
29 This ensures that only users on local box with read/write access to that
30 path can access the VNC server. To securely access the VNC server from a
31 remote machine, a combination of netcat+ssh can be used to provide a secure
32 tunnel.
34 @node vnc_sec_password
35 @subsection With passwords
37 The VNC protocol has limited support for password based authentication. Since
38 the protocol limits passwords to 8 characters it should not be considered
39 to provide high security. The password can be fairly easily brute-forced by
40 a client making repeat connections. For this reason, a VNC server using password
41 authentication should be restricted to only listen on the loopback interface
42 or UNIX domain sockets. Password authentication is not supported when operating
43 in FIPS 140-2 compliance mode as it requires the use of the DES cipher. Password
44 authentication is requested with the @code{password} option, and then once QEMU
45 is running the password is set with the monitor. Until the monitor is used to
46 set the password all clients will be rejected.
48 @example
49 @value{qemu_system} [...OPTIONS...] -vnc :1,password -monitor stdio
50 (qemu) change vnc password
51 Password: ********
52 (qemu)
53 @end example
55 @node vnc_sec_certificate
56 @subsection With x509 certificates
58 The QEMU VNC server also implements the VeNCrypt extension allowing use of
59 TLS for encryption of the session, and x509 certificates for authentication.
60 The use of x509 certificates is strongly recommended, because TLS on its
61 own is susceptible to man-in-the-middle attacks. Basic x509 certificate
62 support provides a secure session, but no authentication. This allows any
63 client to connect, and provides an encrypted session.
65 @example
66 @value{qemu_system} [...OPTIONS...] \
67   -object tls-creds-x509,id=tls0,dir=/etc/pki/qemu,endpoint=server,verify-peer=no \
68   -vnc :1,tls-creds=tls0 -monitor stdio
69 @end example
71 In the above example @code{/etc/pki/qemu} should contain at least three files,
72 @code{ca-cert.pem}, @code{server-cert.pem} and @code{server-key.pem}. Unprivileged
73 users will want to use a private directory, for example @code{$HOME/.pki/qemu}.
74 NB the @code{server-key.pem} file should be protected with file mode 0600 to
75 only be readable by the user owning it.
77 @node vnc_sec_certificate_verify
78 @subsection With x509 certificates and client verification
80 Certificates can also provide a means to authenticate the client connecting.
81 The server will request that the client provide a certificate, which it will
82 then validate against the CA certificate. This is a good choice if deploying
83 in an environment with a private internal certificate authority. It uses the
84 same syntax as previously, but with @code{verify-peer} set to @code{yes}
85 instead.
87 @example
88 @value{qemu_system} [...OPTIONS...] \
89   -object tls-creds-x509,id=tls0,dir=/etc/pki/qemu,endpoint=server,verify-peer=yes \
90   -vnc :1,tls-creds=tls0 -monitor stdio
91 @end example
94 @node vnc_sec_certificate_pw
95 @subsection With x509 certificates, client verification and passwords
97 Finally, the previous method can be combined with VNC password authentication
98 to provide two layers of authentication for clients.
100 @example
101 @value{qemu_system} [...OPTIONS...] \
102   -object tls-creds-x509,id=tls0,dir=/etc/pki/qemu,endpoint=server,verify-peer=yes \
103   -vnc :1,tls-creds=tls0,password -monitor stdio
104 (qemu) change vnc password
105 Password: ********
106 (qemu)
107 @end example
110 @node vnc_sec_sasl
111 @subsection With SASL authentication
113 The SASL authentication method is a VNC extension, that provides an
114 easily extendable, pluggable authentication method. This allows for
115 integration with a wide range of authentication mechanisms, such as
116 PAM, GSSAPI/Kerberos, LDAP, SQL databases, one-time keys and more.
117 The strength of the authentication depends on the exact mechanism
118 configured. If the chosen mechanism also provides a SSF layer, then
119 it will encrypt the datastream as well.
121 Refer to the later docs on how to choose the exact SASL mechanism
122 used for authentication, but assuming use of one supporting SSF,
123 then QEMU can be launched with:
125 @example
126 @value{qemu_system} [...OPTIONS...] -vnc :1,sasl -monitor stdio
127 @end example
129 @node vnc_sec_certificate_sasl
130 @subsection With x509 certificates and SASL authentication
132 If the desired SASL authentication mechanism does not supported
133 SSF layers, then it is strongly advised to run it in combination
134 with TLS and x509 certificates. This provides securely encrypted
135 data stream, avoiding risk of compromising of the security
136 credentials. This can be enabled, by combining the 'sasl' option
137 with the aforementioned TLS + x509 options:
139 @example
140 @value{qemu_system} [...OPTIONS...] \
141   -object tls-creds-x509,id=tls0,dir=/etc/pki/qemu,endpoint=server,verify-peer=yes \
142   -vnc :1,tls-creds=tls0,sasl -monitor stdio
143 @end example
145 @node vnc_setup_sasl
147 @subsection Configuring SASL mechanisms
149 The following documentation assumes use of the Cyrus SASL implementation on a
150 Linux host, but the principles should apply to any other SASL implementation
151 or host. When SASL is enabled, the mechanism configuration will be loaded from
152 system default SASL service config /etc/sasl2/qemu.conf. If running QEMU as an
153 unprivileged user, an environment variable SASL_CONF_PATH can be used to make
154 it search alternate locations for the service config file.
156 If the TLS option is enabled for VNC, then it will provide session encryption,
157 otherwise the SASL mechanism will have to provide encryption. In the latter
158 case the list of possible plugins that can be used is drastically reduced. In
159 fact only the GSSAPI SASL mechanism provides an acceptable level of security
160 by modern standards. Previous versions of QEMU referred to the DIGEST-MD5
161 mechanism, however, it has multiple serious flaws described in detail in
162 RFC 6331 and thus should never be used any more. The SCRAM-SHA-1 mechanism
163 provides a simple username/password auth facility similar to DIGEST-MD5, but
164 does not support session encryption, so can only be used in combination with
165 TLS.
167 When not using TLS the recommended configuration is
169 @example
170 mech_list: gssapi
171 keytab: /etc/qemu/krb5.tab
172 @end example
174 This says to use the 'GSSAPI' mechanism with the Kerberos v5 protocol, with
175 the server principal stored in /etc/qemu/krb5.tab. For this to work the
176 administrator of your KDC must generate a Kerberos principal for the server,
177 with a name of 'qemu/somehost.example.com@@EXAMPLE.COM' replacing
178 'somehost.example.com' with the fully qualified host name of the machine
179 running QEMU, and 'EXAMPLE.COM' with the Kerberos Realm.
181 When using TLS, if username+password authentication is desired, then a
182 reasonable configuration is
184 @example
185 mech_list: scram-sha-1
186 sasldb_path: /etc/qemu/passwd.db
187 @end example
189 The @code{saslpasswd2} program can be used to populate the @code{passwd.db}
190 file with accounts.
192 Other SASL configurations will be left as an exercise for the reader. Note that
193 all mechanisms, except GSSAPI, should be combined with use of TLS to ensure a
194 secure data channel.