Title: openSSH - the open Secure Shell Author: Lukas Kallies Date: Oct 25 2007 ____ ____ _ _ ___ _ __ ___ _ __ / ___/ ___|| | | | / _ \| '_ \ / _ \ '_ \\___ \___ \| |_| | | (_) | |_) | __/ | | |___) |__) | _ | \___/| .__/ \___|_| |_|____/____/|_| |_| |_| the open Secure Shell SYN ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * URL/Lizenz * einfache Verbindungen * Portforwarding * Befehlsuebergabe * Escape-Sequencen * Konfiguration * KeyAuthentication * X-Forwarding * Tools URL, Pakete, Lizenz ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ URL * http://www.openssh.com/ Lizenz * steht unter BSD Lizenz Howto install * aptitude install openssh-server openssh-client * emerge openssh * oder gleich: .--------------------------- | wget ftp://ftp.openbsd.org/pub/OpenBSD/OpenSSH/portable/openssh-3.7p1.tar.gz && | tar xvfz openssh-4.7p1.tar.gz && \ | cd openssh-4.7p1 && ./configure && make && make install `--------------------------- URL, Pakete, Lizenz [2] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * Windows * OpenSSH ueber Cygwin * http://sshwindows.sourceforge.net/ * PuTTY * PSCP * PSFTP * ... * WinSCP Need help? * man [ssh|scp|sftp|ssh-add|ssh-agent|ssh-argv0|ssh-keygen|ssh-keyscan|ssh_config|ssh- eysign|sshd|sshd_config|sftp-server] SSH Verbindungen ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .--------------------------- | $ ssh user@host | user@host's password: | Linux host 2.6.18-5-486 #1 Fri Jun 1 00:07:22 UTC 2007 i686 | No mail. | Last login: Thu Oct 25 09:21:16 2007 | $ #interaktive Ausfuehrung `--------------------------- Alternative Angabe des Benutzernamens: * ssh -l user host SSH Verbindung abbauen ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * exit, logout, quit... * +D * ~. * siehe "the big escape" * /sbin/shutdown -h now # ;-) SCP Verbindungen ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .--------------------------- | $ scp user@host:remoteFileToCopy localCopy | user@lhost's password: | remoteFileToCopy 100% 0 0.0KB/s 00:00 `--------------------------- .--------------------------- | $ scp localFileToCopy user@host:remoteCopy | user@host's password: | localFileToCopy 100% 0 0.0KB/s 00:00 `--------------------------- Nicht interaktiv! * "remoteCopy" muss nicht angegeben werden, ":" IMMER, ansonsten gleiche Wirkung wie .--------------------------- | $ cp localFileToCopy user@host `--------------------------- SFTP Verbindungen ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .--------------------------- | $ sftp user@host | Connecting to host... | user@host's password: | $ sftp>#interaktive Ausfuehrung `--------------------------- Nahezu identisch zu ftp, aber eben "secure". Portforwarding ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * Tunneln lokaler (serverseitiger TCP-) Ressourcen .--------------------------- | ssh user@host -L 8080:remoteDestinationHost:80 `--------------------------- * Tunneln entfernter (serverseitiger TCP-) Ressourcen .--------------------------- | ssh user@host -R 8080:localDestinationHost:80 `--------------------------- * Dynamische Portweiterleitung (SOCKS) .--------------------------- | ssh user@host -D 8080 `--------------------------- z.B. unter firef^Wiceweasel SOCKS Proxy einstellen und munter tunneln. ACHTUNG: Nur weil die Verbindung verschluesselt erfolgt, heisst das nicht, dass ein Netadmin nichts davon mitbekommt Tunnel ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * Tunnel mit tun/tap Device (ab openSSH 4.3) * absoluter Overhead (zumindest fuer permanente Verbindungen) * besser: IPSec, ... Befehlsuebergabe ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .--------------------------- | ssh user@host "ls -l file" | | ssh user@host "echo \"content\" > file" | | ssh user@host "ls -l file" | | ssh user@host "cat file" > localfile `--------------------------- * Es koennen fast beliebig Befehle abgesetzt werden. * Unschoen ist die Verwendung von Leerzeichen in Dateinamen (as usual) * ssh user@host cat remote\\\ file bzw. ssh user@host "cat remote\ file" the big escape ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * Escapezeichen per default "~" * veraenderbar mit -e "*" Supported escape sequences: ~? - this message ~. - terminate connection ~^Z - suspend ssh ~& - background ssh (when waiting for connections to terminate) ~# - list forwarded connections ~~ - send the escape character by typing it twice ~B - send a BREAK to the remote system ~C - open a command line ~R - Request rekey (SSH protocol 2 only) (Note that escapes are only recognized immediately after newline.) sshd_config ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .--------------------------- | Port 22 | # evtl. Highport | Protocol 2 | PermitRootLogin off | PubkeyAuthentication yes | PermitEmptyPasswords no | X11Forwarding yes | UsePAM yes `--------------------------- ssh_config ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .--------------------------- | Host * | HashKnownHosts yes | Protocol 2 | Host MyHost | Port 2222 | EscapeChar % | User myuser `--------------------------- ~/.ssh/known_hosts ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .--------------------------- | $ ssh-keygen -F ftp.fh-furtwangen.de | # Host ftp.fh-furtwangen.de found: line 13 type RSA | |1|ZkDX7wIzCH8QvDA1hcQZs2qK3gQ=|mukfQSmSjAkLsxbeBEXI0FqqzKY= ssh-rsa | AAAAB3NzaC1yc2EAAAABIwAAAIEAvy97TnJLM3ugd6vCFasgoigrK0hSJqZuxGxsxdY7IlsgES9NYx2n | Pz+1lXKU6zAleom1oo8roMYiSyfS6xutnTK2oR/Mz5cxzuwkRrWmX2WWJ2UGp4+aE5biIrTaPwjIjwWD | KOXuNy3/B4km7SN0tmvLuto4EefSOsPh2n6Qc= `--------------------------- * Moeglichkeit zu erkennen ob sich der Hostschluessel geaendert hat * Spoofing * Neuinstallation des Servers * neuer Schluessel Key-Authentication ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .--------------------------- | ssh-keygen -t rsa `--------------------------- ~/.ssh/id_rsa.pub auf Zielrechner in ~/.ssh/authorized_keys kopieren * ssh-keygen * ssh-keyscan * ssh-agent * ssh-add X-Forwarding ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .--------------------------- | ssh -X user@host # eingeschraenkt | | ssh -Y user@ftp.fh-furtwangen.de # uneingeschraenkt `--------------------------- Nach Verbindungsaufbau koennen nahezu alle grafischen Tools verwendet werden. Tools ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Was waere SSH ohne alle unseren netten Tools? * screen (a must) * centerim (Jabber, ICQ, IRC, ...) * irssi (IRC) * rsync (backup) * mutt (mail) * vim (Eierlegendewollmilchsau) * vim scp://user@host/path * :Nread scp://user@host/path * :Nwrite scp://user@host/path * XEmacs ("all", can even edit files) * /[user@host]path * MIT den Klammern Quellen ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * SSH kurz & gut, 2. Auflage (2006), Sven Riedel, O'Reilly Verlag Koeln * http://de.wikipedia.org/wiki/OpenSSH FIN ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ eMail: kallies [at] informatik.hs-furtwangen.de PGP Key ID: 0x336EEEC4 PGP Fingerprint: 941A A11B 5156 B94F 13EC 90E2 3F35 E3E2 336E EEC4 ___ ___ _ _ | __||_ _|| \| | | _| | | | .` | |_| |___||_|\_|