piping added
[linuxnijmegen-ssh.git] / truuk.tex
1 \begin{frame}[fragile]
2 \frametitle{Public key authentication}
3 \pause
4 \begin{block}{Nut}
5 Mogelijk geen wachtwoord en veiliger
6 \end{block}
7 \pause
8 \begin{block}{Command line vlag}
9 \lstinline{ssh -i ~/.ssh/keyfile frobnicator@foobarbaz.com}
10 \end{block}
11 \pause
12 \begin{block}{Config file}
13 \lstinline{IdentityFile ~/.ssh/keyfile}
14 \end{block}
15 \end{frame}
16
17 \begin{frame}[fragile]
18 \frametitle{Public key authentication}
19 \framesubtitle{Genereren van een sleutelpaar}
20 \begin{block}{\$ ssh-keygen}
21 \begin{lstlisting}
22 Generating public/private rsa key pair.
23 Enter file in which to save the key (/home/frobnicator/.ssh/id_rsa):
24 /home/frobnicator/.ssh/github
25 Enter passphrase (empty for no passphrase):
26 Enter same passphrase again:
27 Your identification has been saved in /home/frobnicator/.ssh/github.
28 Your public key has been saved in /home/frobnicator/.ssh/github.pub.
29 The key fingerprint is:
30 92:92:6e:b8:3f:d5:76:e8:1b:73:ed:97:c4:e5:87:ba frobnicator@foobarbaz
31 The key's randomart image is:
32 +--[ RSA 2048]----+
33 | |
34 | |
35 | |
36 | . . .|
37 | o o.S. . + |
38 | o ...+ .. + o|
39 | . o. oo.. .o ..|
40 | o. .+ .. o |
41 | .... .. Eo |
42 +-----------------+
43 \end{lstlisting}
44 \end{block}
45 \end{frame}
46
47 \begin{frame}[fragile]
48 \frametitle{Public key authentication}
49 \framesubtitle{Installeren van een sleutel}
50 \begin{block}{Publieke sleutel: \textasciitilde/.ssh/github.pub}
51 \begin{lstlisting}
52 ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDBrgcK05XzRRbtmPyXQner5ef8
53 suOAErDvInRDQbl2bjR0PGizL2t5lM9zE+mS0HHigteGLKma1NxVBBeam0CrodJN
54 BcW55x3LR/2fLSujUqcloQNwLUpD5da6eGg9yPo1fEaAOK1ssHGA30o6nmDEZEHy
55 PFgBtPwtDw5TPXPpzslaJx1u7CdeyzqpYsUycxzboy3GBcCsvG4nzD4C9vd0yk5o
56 jlDeECul4mwyg7NuEjltaY89RzrSa8NtqtURyg/JFQW2IVGe+oBXeTL/eQRuo1Nj
57 GhYyPm1VMVM+NvaYQZXxGfLpoDoP2V+deD+gP5DuC8WW4LSGnkHKhDEin0Yl foo
58 @foobarbaz
59 \end{lstlisting}
60 \end{block}
61 \pause
62 \begin{block}{Geheime sleutel: \textasciitilde/.ssh/github}
63 \begin{lstlisting}
64 -----BEGIN RSA PRIVATE KEY-----
65 9RnNnrD2DkJBqoX/Aph2wVZg1y/I8t27C7yPR66xUNyHWG4J+k+q7REhA/K4fvjl
66 NNvNtbc4EeNI+NxaaftH1qo6yBIF5yDwuEYKixeconLCeGl9/exdlyMyXbuuTrU9
67 d5DgKnWxgJPHnDjmwqTeX3A5S34m/qJKK67IF9WqedeHxeMKzMZYcZpcsFxdvHk/
68 ...
69 -----END RSA PRIVATE KEY-----
70 \end{lstlisting}
71 \end{block}
72 \pause
73 \begin{block}{Installeren op de server}
74 De inhoud van het publieke bestand moet in
75 \lstinline{~/.ssh/authorized_keys} komen te staan
76 \end{block}
77 \end{frame}
78
79 \begin{frame}[fragile]
80 \frametitle{Public key authentication}
81 \pause
82 \begin{block}{\textasciitilde/.ssh/authorized\_keys}
83 \begin{lstlisting}
84 option1="option1value",option2="option2value"...optionn="optionnvalue" ssh-rsa\
85 AAAB4N.....
86 \end{lstlisting}
87 \end{block}
88 \pause
89 \begin{block}{Merk op}
90 alles in \textasciitilde/.ssh/ moet alleen leesbaar zijn voor de user.
91 \lstinline{chmod 600} dus
92 \end{block}
93 \end{frame}
94
95 \begin{frame}[fragile]
96 \frametitle{Pipen}
97 \begin{block}{Nut}
98 Spreekt voor zich
99 \end{block}
100 \pause
101 \begin{block}{Basisvoorbeelden}
102 \begin{enumerate}
103 \item{server$\rightarrow$client}\\
104 \lstinline{ssh frobnicator@foobarbaz.com 'ls -allah /media/cdrom'}
105 \item{client$\rightarrow$server}\\
106 \lstinline{ls -allah /media/cdrom | ssh frobnicator@foobarbaz.com 'cat - > cdrom_client.txt'}
107 \end{enumerate}
108 \end{block}
109 \pause
110 \begin{block}{Praktijk}
111 \begin{enumerate}
112 \item{Backup}\\
113 \lstinline{dd if=/dev/sdb | gzip | ssh frobnicator@foobarbaz.com 'gzip -d | dd of=sdb.img'}
114 \item{Script draaien}\\
115 \lstinline{ssh frobnicator@foobarbaz.com 'bash -s' < script.sh}
116 \item{Liedje afspelen}\\
117 \lstinline{ssh frobnicator@foobarbaz.com 'cat ~/liedje.flac' | flac -dsc - | aplay}
118 \end{enumerate}
119 \end{block}
120 \end{frame}
121
122
123 \begin{frame}[fragile]
124 \frametitle{X forwarding}
125 \begin{block}{Nut}
126 Grafische programma's draaien op een machine die niet perse binnen
127 handbereik is.
128 \end{block}
129 \pause
130 \begin{block}{Command line vlag}
131 \lstinline{ssh -X frobnicator@foobarbaz.com}
132 \end{block}
133 \pause
134 \begin{block}{Config file}
135 \lstinline{ForwardX11 yes}
136 \end{block}
137 \pause
138 \begin{block}{Caveat}
139 Veiligheid
140 \end{block}
141 \end{frame}
142
143 \begin{frame}
144 \frametitle{Port forwarding}
145 \begin{block}{Nut}
146 Onversleutelde communicatie versleutelen
147 \end{block}
148 \pause
149 \begin{block}{Command line vlag}
150 \lstinline{ssh -L port:host:hostport frobnicator@foobarbaz.com}\\
151 \lstinline{ssh -R port:host:hostport frobnicator@foobarbaz.com}
152 \end{block}
153 \pause
154 \begin{block}{Config file}
155 \lstinline{LocalForward port host:hostport}\\
156 \lstinline{RemoteForward port host:hostport}
157 \end{block}
158 \end{frame}
159
160 \begin{frame}
161 \frametitle{Agent forwarding}
162 \begin{block}{Nut}
163 Je SSH cache meenemen naar een andere server
164 \end{block}
165 \pause
166 \begin{block}{Command line vlag}
167 \lstinline{ssh -A frobnicator@foobarbaz.com}
168 \end{block}
169 \pause
170 \begin{block}{Config file}
171 \lstinline{ForwardAgent yes}
172 \end{block}
173 \end{frame}
174
175 \begin{frame}
176 \frametitle{SOCKS proxy}
177 \begin{block}{Nut}
178 Al je internet verkeer via een \textit{vertrouwde} locatie laten lopen
179 \end{block}
180 \pause
181 \begin{block}{Command line vlag}
182 \lstinline{ssh -D port frobnicator@foobarbaz.com}
183 \end{block}
184 \pause
185 \begin{block}{Config file}
186 \lstinline{DynamicForward port}
187 \end{block}
188 \pause
189 \begin{block}{Instellen in Chromium}
190 \lstinline{chromium --proxy-server="socks5://host:8080" --host-resolver-rules="MAP * 0.0.0.0 , EXCLUDE host"}
191 \end{block}
192 \end{frame}
193
194 \begin{frame}
195 \frametitle{Instellen in Firefox}
196 Edit - Preferences - Advanced - Network - Settings
197 \includegraphics[width=200px]{./img/firefox_socks.png}
198 \end{frame}
199
200 \begin{frame}[fragile]
201 \frametitle{Compression}
202 \begin{block}{Nut}
203 Snelheid
204 \end{block}
205 \pause
206 \begin{block}{Command line vlag}
207 \lstinline{ssh -C frobnicator@foobarbaz.com}
208 \end{block}
209 \pause
210 \begin{block}{Config file}
211 \lstinline{Compression yes}
212 \end{block}
213 \end{frame}