]> piware.de Git - talk-cockpit-auth-anywhere.git/blob - cockpit-auth-anywhere.md
b5a53c27f70e77f33144550773449f7da814dff4
[talk-cockpit-auth-anywhere.git] / cockpit-auth-anywhere.md
1 ---
2 title: Authenticate to Cockpit from anywhere
3 subtitle:
4 author: Martin Pitt <<mpitt@redhat.com>>
5 email: mpitt@redhat.com
6 date: DevConv.CZ 2020
7 theme: Singapore
8 header-includes:
9  - \setbeameroption{show notes}
10  - \newcommand{\fullsizeimg}[1]{\makebox[\linewidth]{\includegraphics[width=\paperwidth]{#1}}}
11 ...
12
13 # Cockpit what?
14
15 - Interactive Server admin web interface
16 - Easy setup and troubleshooting for one or a few machines
17 - Included in all major distros
18
19 :::notes
20 - Conceptually: Linux session running in a web browser; technically very similar to ssh/VT/GNOME login
21 - Aimed at admins who are new to Linux, e. g. coming from the Windows world and familiar with the concepts, but not Linux terminology
22 - but also to experienced ones for infrequent tasks; not just setup, but also investigating “what is wrong with this machine”
23 :::
24
25
26 # Extending LVM
27
28 ```sh
29 pvcreate /dev/sdb2
30 vgextend vg0 /dev/sdb2
31 lvresize --extents '+100%FREE' vg0/data1
32 resize2fs /dev/vg0/data1
33 ```
34
35 :::notes
36 - for example, adding a new PV to an LV and resizing the file system you can spend some time coming up with these commands
37 - lots of possibilities for screwing up
38 - you can do it simply and safely with Cockpit like this → go to local browser
39 - Storage page, vg0 in Devices (top right), + in Physical Volumes, add sdb2
40 - expand data1 table line, click grow
41 :::
42
43 # Accessible from any browser
44
45  - Windows/Edge
46  - Mobile devices
47  - Simple install
48  - Zero configuration
49
50 :::notes
51 - Switch to Windows virt-viewer, open Edge, show Cockpit
52 - Quit virt-viewer
53 - Move to local browser, enable mobile mode (Ctrl+Shift+M)
54 - Zero configuration so far, other than possibly installing cockpit pkg and enabling cockpit.socket
55 - In larger environments it's impractical to install cockpit server on hundreds
56   of machines and using the login web page
57 - Glimpse of how to customize how cockpit runs and how to authenticate to it
58 :::
59
60 # Anatomy: cockpit-ws
61
62 ![ws-session](ws-session.pdf)\ 
63
64 - TCP http+WebSocket $\leftrightarrow$ JSON pipe
65 - collect credentials
66
67 :::notes
68 - for configuring, extending, and embedding Cockpit you need to coarsely understand the components of it
69 - this: simplest structure, what I just showed you and what you will most probably see the first time you try it
70 - browser only speaks HTTP and WebSocket, so you always need a web server, cockpit-ws
71 - all components in cockpit communicate to each other via a JSON protocol on standard pipes, usually stdio
72 - this provides a lot of flexibility and extensibility, as we'll see shortly
73 - ws roles: communicate with the browser for getting credentials: login page, krb negotiation, client cert
74 - ws: deliver HTML/js content, connects JSON protocol on the WebSocket to pipes to the other components; runs as unprivileged system user
75 :::
76
77 # Anatomy: cockpit-session
78
79 ![ws-session](ws-session.pdf)\ 
80
81 - ws credentials → PAM session
82 - forward JSON pipe to session leader
83
84 :::notes
85 - need some root helper to actually start session: use creds from ws to start PAM login session, connect pipe to it
86 - standard is cockpit-session: very small, auditable
87 - but doesn't have to be, that's the flexible part
88 :::
89
90 # Anatomy: cockpit-bridge
91
92 ![ws-session](ws-session.pdf)\ 
93
94 - session leader, cockpit's "bash"
95 - JSON on stdio $\leftrightarrow$ system APIs
96
97 :::notes
98 - bridge: session leader, moral equivalent of what bash is in ssh session
99 - JSON protocol on stdio to system APIs: exec programs, call D-Bus, work with files or sockets
100 - runs as target user in login session; complex, but no special privileges
101 :::
102
103 # SSH sessions
104
105 ![ssh-session](ssh-session.pdf)\ 
106
107 nothing Cockpit specific running outside of the user session
108
109 :::notes
110 - ws and the login session don't need to run on the same machine
111 - cockpit-session is meant to be customizable for your purposes
112 - most obvious replacement is to let ssh start a session; that already does the
113   PAM bits and forward its initial stdio to the session lead; it would just
114   launch cockpit-bridge instead of bash
115 - browser: go to Dashboard, add cockpit.dev:2201
116 - interesting property: nothing Cockpit specific running in the system, no ws,
117   no extra open port; only bit is bridge, but that's uninteresting from security POV
118 :::
119
120 # Bastion host
121
122 ![bastion-host](bastion-host.pdf)\ 
123
124 Enforce using ssh in cockpit.conf(5):
125 ```ini
126 [WebService]
127 RequireHost=true
128 ```
129
130 :::notes
131 - further illustrated by a mode that we call "bastion host"
132 - disable cockpit-session and local logins, only use ssh
133 - can run in container
134 - no ws on critical machines, don't trust cockpit-session
135 - switch to browser; log out, use "connect to" for cockpit.dev:2201
136 :::
137
138 # Other authentication setups
139
140 - SSO/Kerberos in Identity Management domains
141 - smart card/client certificate authentication
142 - OAuth (Kubernetes)
143 - Foreman: included cockpit-ws with dynamic configuration
144
145 TODO: foreman screenshot
146
147 :::notes
148 - Cockpit supports common authentication systems out of the box
149 - IdM is very common; if you have a krb ticket, you get a session immediately
150   without the login page
151 - browsers can ask for TLS client certificates, commonly with smart cards, and
152   present them to the web server; latest Cockpit versions supports that
153 - Foreman has a "Web Console" button; already has ssh to all maintained
154   machines
155 - runs a single cockpit-ws process on its server, and dynamically configures it
156   for selected target machine, seamless transition between Foreman and Cockpit
157 - not enough time to demo and explain all of this; just keep in mind that it's
158   possible
159 :::
160
161 # Custom authentication example
162
163 TODO
164
165 # Q & A
166
167 Contact:
168
169 - `#cockpit` on Freenode
170 - https://cockpit-project.org
171
172 Useful links:
173
174  * [Authentication configuration](https://cockpit-project.org/guide/latest/authentication.html)
175  * [Authentication protocol](https://github.com/cockpit-project/cockpit/blob/master/doc/authentication.md)
176
177 :::notes
178 - Home page leads to mailing lists, documentation
179 - thanks for your attention; Q+A
180 :::