306 lines
		
	
	
		
			11 KiB
		
	
	
	
		
			HTML
		
	
	
	
	
	
			
		
		
	
	
			306 lines
		
	
	
		
			11 KiB
		
	
	
	
		
			HTML
		
	
	
	
	
	
<!doctype html>
 | 
						|
<html lang="de">
 | 
						|
		<meta charset="utf-8">
 | 
						|
 | 
						|
		<title>Einführung in Linux</title>
 | 
						|
 | 
						|
		<meta name="description" content="YALC - Yet Another Linux Course ">
 | 
						|
		<meta name="author" content="Daniel Schubert">
 | 
						|
 | 
						|
		<meta name="apple-mobile-web-app-capable" content="yes">
 | 
						|
		<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
 | 
						|
 | 
						|
		<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
 | 
						|
 | 
						|
		<link rel="stylesheet" href="css/reveal.css">
 | 
						|
		<link rel="stylesheet" href="css/theme/league.css" id="theme">
 | 
						|
		
 | 
						|
		<link rel="icon" href="img/openlogo-nd-25.png" type="img/png">
 | 
						|
 | 
						|
		<!-- Theme used for syntax highlighting of code -->
 | 
						|
		<link rel="stylesheet" href="lib/css/zenburn.css">
 | 
						|
 | 
						|
		<!-- Printing and PDF exports -->
 | 
						|
		<script>
 | 
						|
			var link = document.createElement( 'link' );
 | 
						|
			link.rel = 'stylesheet';
 | 
						|
			link.type = 'text/css';
 | 
						|
			link.href = window.location.search.match( /print-pdf/gi ) ? 'css/print/pdf.css' : 'css/print/paper.css';
 | 
						|
			document.getElementsByTagName( 'head' )[0].appendChild( link );
 | 
						|
		</script>
 | 
						|
		<style type="text/css">
 | 
						|
			.reveal img{ max-height: 60vh}
 | 
						|
		</style>
 | 
						|
 | 
						|
	</head>
 | 
						|
 | 
						|
	<body>
 | 
						|
		<div class="reveal">
 | 
						|
			<!-- Any section element inside of this container is displayed as a slide -->
 | 
						|
			<div class="slides">
 | 
						|
 | 
						|
				<section data-transition="slide" data-background="#4d7e65" data-background-transition="zoom">
 | 
						|
					<h1>LINUX</h1>
 | 
						|
					<h3>Das universelle Betriebssystem</h3>
 | 
						|
					<p>Eine Einführung - Teil 11
 | 
						|
					<p> <small>Deutsche Angestellten Akademie</small> </p>
 | 
						|
					<aside class="notes">
 | 
						|
						Frage: Fragen zur letzten Stunde?
 | 
						|
					</aside>
 | 
						|
				</section>
 | 
						|
 | 
						|
				<section  data-transition="slide" data-background="#b5533c" data-background-transition="convex">
 | 
						|
					<h3>ssh</h3>
 | 
						|
					SSH ermöglicht eine <span class="fragment highlight-green">sichere, authentifizierte und verschlüsselte</span> Verbindung zwischen zwei Rechnern über ein unsicheres Netzwerk.
 | 
						|
				</section>
 | 
						|
 | 
						|
				<section style="font-size: .7em">
 | 
						|
					<div>
 | 
						|
						<p ><strong style="text-decoration: underline ">Secure System Administration (Sichere Systemverwaltung)</strong style="text-decoration: underline ">
 | 
						|
						zur Absicherung der Fernverwaltung von Servern. 
 | 
						|
						Secure Application Tunneling (Sicheres Tunneln)
 | 
						|
						zum transparenten Schutz TCP/IP-basierender Anwendungen als „End-to-End-Security“.</div>
 | 
						|
					<div class="fragment">
 | 
						|
						<p ><strong style="text-decoration: underline ">Secure Remote Command Execution (Sichere Ausführung von Kommandos)</strong style="text-decoration: underline ">
 | 
						|
						zur Ausführung einzelner Kommandos auf einem anderen Rechner. Dabei werden stdin, stdout und stderr transparent weitergeleitet. Sonderfall davon:
 | 
						|
						</div>
 | 
						|
					<div class="fragment">
 | 
						|
						<p><strong style="text-decoration: underline ">Secure Subsystem Execution (Sichere Ausführung von Subsystemen)</strong style="text-decoration: underline ">
 | 
						|
						zur Ausführung von auf dem Server vordefinierter Kommandos, wobei stderr jedoch nicht weitergeleitet wird.
 | 
						|
						Beispiel: Secure File Transfer (Sicherer Dateitransfer)
 | 
						|
						zur Herstellung sicherer, automatisierter und interaktiver Dateitransfers.
 | 
						|
					</div>		
 | 
						|
				</section>
 | 
						|
 | 
						|
				<section>
 | 
						|
					<img src="img/how-does-ssh-protocol-work-920x272-SWKuhzNV.png">
 | 
						|
				</section>
 | 
						|
 | 
						|
 | 
						|
				<section>
 | 
						|
					<h4>Funktionsweise</h4>
 | 
						|
 | 
						|
					<ul>
 | 
						|
						<li class="fragment ">Server identifiziert sich mit Zertifikat</li>
 | 
						|
						<li class="fragment ">Client authentisiert sich mit Passwort od. Zertifikat</li>
 | 
						|
						<li class="fragment ">geheimer Schlüssel wird erzeugt für die Sitzung</li>
 | 
						|
						<li class="fragment ">Datenverkehr wird mit diesem Schlüssel verschlüsselt übertragen</li>
 | 
						|
					</ul>
 | 
						|
				</section>
 | 
						|
 | 
						|
				<section>
 | 
						|
					<h4>Programme</h4>
 | 
						|
					<ul>
 | 
						|
						<li class="fragment ">ssh -> ...</li>
 | 
						|
						<li class="fragment ">scp -> Dateien über ssh kopieren</li>
 | 
						|
						<li class="fragment ">ssh-keygen -> Schlüssel erstellen</li>
 | 
						|
						<li class="fragment ">ssh-copy-id -> Schlüssel austauschen</li>
 | 
						|
						<li class="fragment ">sshd -> der ssh-Server</li>
 | 
						|
					</ul>
 | 
						|
				</section>
 | 
						|
 | 
						|
				<section>
 | 
						|
					<h4>Verwendung</h4>
 | 
						|
					<ul>
 | 
						|
						<li class="fragment ">systemweite client Konfiguration: <code>/etc/ssh/ssh_config</code> </li>
 | 
						|
						<li class="fragment "><pre><code class="bash">~$ ssh [ -p port ] [user@]host</code></pre></li>
 | 
						|
						<li class="fragment ">Wird kein User angegeben, nimmt ssh aktuellen User.</li>
 | 
						|
						<li class="fragment "><pre><code class="bash">~$ ssh -p 1234 root@omikron.net</code></pre></li>
 | 
						|
						<li class="fragment "><pre><code class="bash">~$ ssh ::1</code></pre></li>
 | 
						|
					</ul>
 | 
						|
				</section>
 | 
						|
 | 
						|
				<section>
 | 
						|
					<h4>Verwendung mit ssh-Keys</h4>
 | 
						|
					<ol style="font-size: .8em">
 | 
						|
						<li class="fragment ">Schlüsselpaar generieren:<br> <pre><code>ssh-keygen -b 4096</code></pre></li>
 | 
						|
						<li class="fragment ">öffentlichen Schlüssel zum Server kopieren:<br> <pre><code>scp neuer-super-key.pub user@server.de</code></pre></li>
 | 
						|
						<li class="fragment ">Beim Server anmelden: <code>ssh user@server.de</code></li>
 | 
						|
						<li class="fragment "><pre><code  class="bash">$ mkdir ~/.ssh
 | 
						|
$ cat ~/neuer-super-key.pub  >> ~/.ssh/authorized_keys
 | 
						|
$ rm ~/neuer-super-key.pub 
 | 
						|
$ chmod 600 ~/.ssh/authorized_keys</code></pre><p class="fragment">Oder mit <code>ssh-copy-id</code></li>
 | 
						|
					<li class="fragment">nun ist Anmeldung mit Key möglich. 
 | 
						|
					</ol>
 | 
						|
 | 
						|
				</section>
 | 
						|
 | 
						|
				<section>
 | 
						|
					<h4>Begriffe</h4>
 | 
						|
					<table style="font-size: .6em">
 | 
						|
						<tr>
 | 
						|
							<td>SSH Key</td>
 | 
						|
							<td>ersetzt Passwort</td>
 | 
						|
						</tr>
 | 
						|
						<tr>
 | 
						|
							<td>authorized keys</td>
 | 
						|
							<td>öffentliche Schlüssel die Zugriff erlauben ( Analogie: Schloß, das vom zugehörigen privaten Schl. geöffnet werden kann.)</td>
 | 
						|
						</tr>
 | 
						|
						<tr>
 | 
						|
							<td>identity key</td>
 | 
						|
							<td>Privater Schlüssel, den SSH verwendet um den client zu authentisieren</td>
 | 
						|
						</tr>
 | 
						|
						<tr>
 | 
						|
							<td>host key</td>
 | 
						|
							<td>öffentlicher SSH-Schlüssel des Servers</td>
 | 
						|
 | 
						|
						</tr>
 | 
						|
						<tr>
 | 
						|
							<td>Session Key</td>
 | 
						|
							<td>wird von den Kommunikations Partner ausgehandelt; verschlüsselt Daten während Übertragung</td>
 | 
						|
						</tr>
 | 
						|
					</table>
 | 
						|
				</section>
 | 
						|
 | 
						|
				<section>
 | 
						|
					<h4>ssh_config</h4>
 | 
						|
					<pre><code class="bash">Host gitlab.com
 | 
						|
	HostName gitlab.com
 | 
						|
	PreferredAuthentications=publickey
 | 
						|
	#PreferredAuthentications=password
 | 
						|
	IdentityFile ~/.ssh/gitlab-com
 | 
						|
	IdentitiesOnly yes
 | 
						|
	User git 
 | 
						|
 | 
						|
Host *
 | 
						|
	user root
 | 
						|
 | 
						|
ServerAliveInterval 120
 | 
						|
ServerAliveCountMax 15
 | 
						|
					</code></pre>
 | 
						|
				</section>
 | 
						|
 | 
						|
				<section>
 | 
						|
					<h4>Nutzungsbeispiele</h4>
 | 
						|
						<pre  class="fragment "><code class="bash">~$ ssh root@server 'cd /etc; \ 
 | 
						|
tar czvf - network/' | cat > etc_network_backup.tar.gz </code></pre>
 | 
						|
						<pre class="fragment "><code>~$ scp -r root@server:/etc/apache2 . </code></pre>
 | 
						|
						<pre class="fragment "><code>~$ scp omikron-net.conf \ 
 | 
						|
root@server:/etc/apache2/sites-available/ . </code></pre>
 | 
						|
						<pre class="fragment "><code class="bash">~$ rsync -e ssh lk.schubertdaniel.de:/home/dany/backups/* \ 
 | 
						|
/local/backup/dir/ >> backup.log 2>&1
 | 
						|
						</code></pre>
 | 
						|
				</section>
 | 
						|
 | 
						|
				<section>
 | 
						|
					<h3>rsync vs. scp</h3>
 | 
						|
					<ul>
 | 
						|
						<li class="fragment ">scp -> funktioniert wie cp; geeignet um schnell mal einzelne Dateien zu kopieren</li>
 | 
						|
						<li class="fragment ">rsync -> für „richtige“ Backups; vergleicht lokales u. remote Verz., kopiert nur Unterschiede</li>
 | 
						|
					</ul>
 | 
						|
				</section>
 | 
						|
 | 
						|
				<section style="font-size: .8em">
 | 
						|
					<span style="color: orange">Aufgabe:</span>
 | 
						|
					<div>
 | 
						|
						<ul>
 | 
						|
							<li>erstellt einen ssh-key ohne Passwort; verwendet diesen key für Folgendes.</li>
 | 
						|
							<li>Erstellt ein script, welches Serverseitig alle Ordner in /usr/share/nginx/html ausser denen die„mich-*” heissen, in ein tar.gz Archiv verpacken. ( zb per Array im script, oder mit einer text-datei als input</li>
 | 
						|
							<li>Erstellt ein script, welches diese Backups mit <strong>rsync</strong> herunterlädt.</li>
 | 
						|
							<li>Das Backup soll die Datei Attribute unverändert belassen<br> ( Datum, Rechte etc ).</li>
 | 
						|
							<li>Erstellt einen Cron-Job, der das wöchentlich macht.</li>
 | 
						|
						</ul>
 | 
						|
 | 
						|
						<p>Hinweise:
 | 
						|
							<ul>
 | 
						|
								<li>cron muss vollständige Pfade angegeben bekommen.<br>
 | 
						|
								<li><code>rsync</code> mit spezifischem key: 
 | 
						|
							<pre><code class="bash">/usr/bin/rsync -e 'ssh -i /home/$USERNAME/.ssh/key-ohne-pw' </code></pre>
 | 
						|
							</ul>
 | 
						|
					</div>
 | 
						|
				</section>
 | 
						|
				<section>
 | 
						|
					<h4>Lösungs Vorschlag</h4>
 | 
						|
					<p><a href="https://git.scytec.de/danthefan/linuxkurs/blob/master/beispiele/11/file-backup.sh">remote backup script</a>
 | 
						|
					<p><a href="https://git.scytec.de/danthefan/linuxkurs/blob/master/beispiele/11/rsync-backup.sh">local rsync script</a>
 | 
						|
				</section>	
 | 
						|
 | 
						|
				<section>
 | 
						|
					<h4>Beschränkung von ssh auf best. Komandos</h4>
 | 
						|
					<pre><code class="bash"># Datei ~/.ssh/authorized_keys
 | 
						|
# führt bei Anmeldung ls aus; lässt keine anderen Kommandos zu
 | 
						|
command="/bin/ls -la ~" ssh-rsa AAAAB3.......
 | 
						|
# oder
 | 
						|
command="/bin/echo You invoked: $SSH_ORIGINAL_COMMAND" ssh-rsa AAAAB..</code></pre>
 | 
						|
					<div class="fragment">
 | 
						|
						<p>Um rsync zu verwenden ist ein wrapper script nötig:
 | 
						|
 | 
						|
						<pre><code class="bash"># Datei ~/.ssh/authorized_keys
 | 
						|
command="/absoluter/pfad/rsync-check.sh" ssh-rsa AAAAB3.......</code></pre>
 | 
						|
 | 
						|
						<pre><code class="bash">#!/bin/bash 
 | 
						|
#
 | 
						|
# rsync-check.sh
 | 
						|
 | 
						|
set -- $SSH_ORIGINAL_COMMAND
 | 
						|
cmd="$1"; shift
 | 
						|
case "$cmd" in
 | 
						|
  scp|rsync) exec "$cmd" "$@" ;;
 | 
						|
          *) echo "ERROR: request not permitted" ;;
 | 
						|
esac</code></pre>
 | 
						|
					</div>
 | 
						|
				</section>
 | 
						|
 | 
						|
				<section><h4>Windows Programme für ssh</h4>
 | 
						|
 | 
						|
				<ul>
 | 
						|
					<li class="fragment ">winscp</li>
 | 
						|
					<li class="fragment ">putty</li>
 | 
						|
					<li class="fragment ">swish</li>
 | 
						|
				</ul></section>
 | 
						|
 | 
						|
				<section>
 | 
						|
					<h4>Linux Helferlein</h4>
 | 
						|
 | 
						|
					<ul>
 | 
						|
						<li>screen</li>
 | 
						|
						<li>byobu</li>
 | 
						|
						<li>tmux</li>
 | 
						|
						<li>terimator</li>
 | 
						|
						<li>tmate</li>
 | 
						|
					</ul>
 | 
						|
 | 
						|
				<aside class="notes">
 | 
						|
					screen isntallieren
 | 
						|
				</aside>
 | 
						|
				</section>
 | 
						|
 | 
						|
				<section><h4>screen</h4>
 | 
						|
					<a href="https://wiki.ubuntuusers.de/Screen/">https://wiki.ubuntuusers.de/Screen/</a>
 | 
						|
				</section>
 | 
						|
 | 
						|
				
 | 
						|
			</div>
 | 
						|
		</div>
 | 
						|
 | 
						|
		<script src="lib/js/head.min.js"></script>
 | 
						|
		<script src="js/reveal.js"></script>
 | 
						|
 | 
						|
		<script>
 | 
						|
 | 
						|
			// More info https://github.com/hakimel/reveal.js#configuration
 | 
						|
			Reveal.initialize({
 | 
						|
				controls: true,
 | 
						|
				progress: true,
 | 
						|
				history: true,
 | 
						|
				center: true,
 | 
						|
 | 
						|
				transition: 'slide', // none/fade/slide/convex/concave/zoom
 | 
						|
 | 
						|
				// More info https://github.com/hakimel/reveal.js#dependencies
 | 
						|
				dependencies: [
 | 
						|
					{ src: 'lib/js/classList.js', condition: function() { return !document.body.classList; } },
 | 
						|
					{ src: 'plugin/markdown/marked.js', condition: function() { return !!document.querySelector( '[data-markdown]' ); } },
 | 
						|
					{ src: 'plugin/markdown/markdown.js', condition: function() { return !!document.querySelector( '[data-markdown]' ); } },
 | 
						|
					{ src: 'plugin/highlight/highlight.js', async: true, callback: function() { hljs.initHighlightingOnLoad(); } },
 | 
						|
					{ src: 'plugin/search/search.js', async: true },
 | 
						|
					{ src: 'plugin/zoom-js/zoom.js', async: true },
 | 
						|
					{ src: 'plugin/notes/notes.js', async: true }
 | 
						|
				]
 | 
						|
			});
 | 
						|
 | 
						|
		</script>
 | 
						|
 | 
						|
	</body>
 | 
						|
</html>
 |