"was, ssh kann auch das?" @ linuxwochen wien 2013

32
SSH

Upload: martin-leyrer

Post on 12-May-2015

638 views

Category:

Technology


1 download

DESCRIPTION

Tipps zum effizienteren Umgang mit und Empfehlungen zum sicheren Betrieb von ssh(d). Sichere Kommandozeile auch von unterwegs mit Mosh. SSH Zwei-Faktor-Authentifizierung mit “Google Authenticator”. Slides von den Linuxwochen 2013.

TRANSCRIPT

Page 1: "Was, SSH kann auch das?" @ Linuxwochen Wien 2013

SSH

Page 2: "Was, SSH kann auch das?" @ Linuxwochen Wien 2013

Wer ist das da vorne?

Martin Leyrer IT Specialist aka. “Mädchen für Alles” bei einem int.

IT-Dienstleister

E-mail: [email protected] Twitter: http://www.twitter.com/leyrer Facebook: https://www.facebook.com/leyrer Blog: http://martin.leyrer.priv.at LinkedIn: http://at.linkedin.com/in/leyrer Xing: www.xing.com/profile/Martin_Leyrer usw. ;)

Page 3: "Was, SSH kann auch das?" @ Linuxwochen Wien 2013

Nicht-Inhalte

Crypto generell Verschlüsselungsmethoden Smartcards

Page 4: "Was, SSH kann auch das?" @ Linuxwochen Wien 2013

ssh

ssh [email protected]

Page 5: "Was, SSH kann auch das?" @ Linuxwochen Wien 2013

Interactive Remote Commands

-t

sorgt dafür, daß die Session steht bis das interaktive remote command beende wurde. (top, vim, nano, less, etc.)

Page 6: "Was, SSH kann auch das?" @ Linuxwochen Wien 2013

Hostname Aliases

~/.ssh/config

Host demo

HostName ssh.example.com

Page 7: "Was, SSH kann auch das?" @ Linuxwochen Wien 2013

Multiple Aliases

~/.ssh/config

Host smtp imap www

HostName %h.work.example.com

Page 8: "Was, SSH kann auch das?" @ Linuxwochen Wien 2013

Keine Benutzernamen

~/.ssh/config

Host demo

HostName ssh.example.com

User m3

Page 9: "Was, SSH kann auch das?" @ Linuxwochen Wien 2013

Keine Paßwörter

$ ssh-keygen$ ssh-copy-id [email protected]

oderlokal ~/.ssh/id_rsa.pub nach remote ~/.ssh/authorized_keys

Page 10: "Was, SSH kann auch das?" @ Linuxwochen Wien 2013

Wirklich keine Paßwörter

SSH-Agentssh-add

Key aus dem Agent entfernenssh-add -D

Page 11: "Was, SSH kann auch das?" @ Linuxwochen Wien 2013

Session logging

ssh demo | tee -a session.log

Page 12: "Was, SSH kann auch das?" @ Linuxwochen Wien 2013

Vim und scp URLs

gvim scp://demo/demo.txt

Page 13: "Was, SSH kann auch das?" @ Linuxwochen Wien 2013

sshfs

$ mkdir mt

$ sshfs demo:. mt/

$ fusermount -u mt/

Page 14: "Was, SSH kann auch das?" @ Linuxwochen Wien 2013

Lokale App, entfernter Dienst

~/.ssh/config:

LocalForward 4242 localhost:5432

Page 15: "Was, SSH kann auch das?" @ Linuxwochen Wien 2013

Von Server zu Server

$ ssh ssh.example.com

m3@ssh % ssh remote.example.com

~/.ssh/config:

Host remotedemo

HostName remote.example.com

User m3

ProxyCommand ssh %[email protected] -W %h:%p

Page 16: "Was, SSH kann auch das?" @ Linuxwochen Wien 2013

Agenten-Weiterleitung

~/.ssh/config

Host *

ForwardAgent yes

Page 17: "Was, SSH kann auch das?" @ Linuxwochen Wien 2013

make faster

/etc/ssh/sshd_config:GSSAPIAuthentication no

Page 18: "Was, SSH kann auch das?" @ Linuxwochen Wien 2013

Top Gear Tuning Tip

Test:yes | pv | ssh ssh.example.com "cat > /dev/null"

Tune:~/.ssh/config:

Host *

Compression yes

CompressionLevel 9

Page 19: "Was, SSH kann auch das?" @ Linuxwochen Wien 2013

Resilient Connections

~/.ssh/config:

Host *

TCPKeepAlive no

ServerAliveInterval 60

ServerAliveCountMax 10

Page 20: "Was, SSH kann auch das?" @ Linuxwochen Wien 2013

Mosh

Client:sudo apt-get install mosh

Server:http://tinyurl.com/d8yyaew

Probleme:It's probably the locale

Page 21: "Was, SSH kann auch das?" @ Linuxwochen Wien 2013

Google 2-factor Authentication

sudo apt-get install libpam-google-authenticator

Als User ausführen: google-authenticator

/etc/pam.d/sshd:auth required pam_google_authenticator.so

/etc/ssh/sshd_config:ChallengeResponseAuthentication yes

Page 22: "Was, SSH kann auch das?" @ Linuxwochen Wien 2013

https://cryptoparty.at/

Page 23: "Was, SSH kann auch das?" @ Linuxwochen Wien 2013

Feedback

https://cfp.linuxwochen.at/de/lww2013/public/events/7

aka.

http://bit.ly/10VRvtL

Page 24: "Was, SSH kann auch das?" @ Linuxwochen Wien 2013

Danksagungen

Smylers für “SSH Can Do That? Productivity Tips for Working with Remote Servers”

maclemon für Umfangreichen Input zu diesem Talk

Page 25: "Was, SSH kann auch das?" @ Linuxwochen Wien 2013

FRAGEN ?

Page 26: "Was, SSH kann auch das?" @ Linuxwochen Wien 2013

Backup Slides

Page 27: "Was, SSH kann auch das?" @ Linuxwochen Wien 2013

Mehrfache Verbindungen

~/.ssh/config

ControlMaster auto

ControlPath /tmp/ssh_mux_%h_%p_%r

Page 28: "Was, SSH kann auch das?" @ Linuxwochen Wien 2013

Managing Master Connections

Master Connection aktiv:ssh -O check remote-host

Master Tag killen:ssh -O exit remote-host

Page 29: "Was, SSH kann auch das?" @ Linuxwochen Wien 2013

Dateien kopieren scp nutzt bestehende Verbindungen

Bash kann remote tab completion bei installierter “Bash Completion”

Verbindungen können auch mit rsync, git, und vielen anderen Tools geteilt werden

Page 30: "Was, SSH kann auch das?" @ Linuxwochen Wien 2013

Verbindungen wiederholen

~/.ssh/config

ControlMaster auto

ControlPath /tmp/ssh_mux_%h_%p_%r

ControlPersist 4h

Page 31: "Was, SSH kann auch das?" @ Linuxwochen Wien 2013

Windows kann das auch

http://www.chiark.greenend.org.uk/~sgtatham/putty/

Page 32: "Was, SSH kann auch das?" @ Linuxwochen Wien 2013

Web Proxies

Corkscrew

ProxyCommand corkscrew proxy.example.org 8080 %h %p