Ssh schnelleinstieg: Unterschied zwischen den Versionen
Zur Navigation springen
Zur Suche springen
| (16 dazwischenliegende Versionen desselben Benutzers werden nicht angezeigt) | |||
| Zeile 1: | Zeile 1: | ||
| + | =Verbindungsaufbau vereinfacht= | ||
| + | [[Datei:ssh-1.png]] | ||
=Server= | =Server= | ||
==Installation== | ==Installation== | ||
*apt-get install ssh | *apt-get install ssh | ||
| − | == | + | ==Konfig Verzeichnis== |
/etc/ssh | /etc/ssh | ||
| − | == | + | ==Konfigurationsdatei== |
| − | + | Beispiel | |
*cat /etc/ssh/sshd | *cat /etc/ssh/sshd | ||
<pre> | <pre> | ||
| Zeile 27: | Zeile 29: | ||
*systemctl restart ssh | *systemctl restart ssh | ||
=Client= | =Client= | ||
| − | == | + | ==Konfigurations Verzeichnis== |
/etc/ssh | /etc/ssh | ||
| − | == | + | ==Heimat Verzeichnis== |
~/.ssh | ~/.ssh | ||
==remote login== | ==remote login== | ||
| Zeile 35: | Zeile 37: | ||
*ssh -l harald rechner | *ssh -l harald rechner | ||
*ssh -p 22 -l harald rechner | *ssh -p 22 -l harald rechner | ||
| − | == | + | ==Ausführen eines Programs auf einem anderem Rechner== |
*ssh harald@rechner date | *ssh harald@rechner date | ||
*ssh harald@rechner pwd | *ssh harald@rechner pwd | ||
*ssh harald@rechner ls -l | *ssh harald@rechner ls -l | ||
| − | == | + | ==Secure copy== |
==local to remote== | ==local to remote== | ||
| − | + | file | |
*scp /etc/hosts harald@rechner:/tmp | *scp /etc/hosts harald@rechner:/tmp | ||
| − | + | directory | |
*scp -r /bin harald@rechner:/tmp | *scp -r /bin harald@rechner:/tmp | ||
| + | ==Schlüsselpaar erstellen== | ||
| + | *ssh-keygen | ||
| + | <pre> | ||
| + | Generating public/private rsa key pair. | ||
| + | Enter file in which to save the key (/root/.ssh/id_rsa): | ||
| + | Enter passphrase (empty for no passphrase): | ||
| + | Enter same passphrase again: | ||
| + | Your identification has been saved in /root/.ssh/id_rsa. | ||
| + | Your public key has been saved in /root/.ssh/id_rsa.pub. | ||
| + | The key fingerprint is: | ||
| + | SHA256:EuZ8a0Ovlq5ZdXXOsUUMH2pPT3NzD8k8bbfXkjq9nsg root@unaris | ||
| + | The key's randomart image is: | ||
| + | +---[RSA 2048]----+ | ||
| + | | .+.| | ||
| + | | o.=o| | ||
| + | | o oB=@| | ||
| + | | + . ..oX#| | ||
| + | | + S . . o+B| | ||
| + | | + + . o ..| | ||
| + | | =.. o . | | ||
| + | | +oo . o o | | ||
| + | | o+o E.+ | | ||
| + | +----[SHA256]-----+ | ||
| + | </pre> | ||
| + | ==Key zum Zielrechner übertragen== | ||
| + | *ssh-copy-id harald@rechner | ||
| + | ==Login testen== | ||
| + | *ssh harald@rechner | ||
| + | = SSH Tunnel (Port Forwarding) = | ||
| + | ==Local Port zu Remote Port Umleitung== | ||
| + | alice port 9999 ---> bob port 8888 | ||
| + | *ssh -4 -f -N bob@bob-host -L 9999:localhost:8888 | ||
| + | {{#drawio:ssh-local-remote}} | ||
| + | |||
| + | ==Remote Port zu Local Port Umleitung== | ||
| + | bob port 7777 ---> alice port 6666 | ||
| + | *ssh -4 -f -N bob-host -R 7777:localhost:6666 | ||
| + | {{#drawio:ssh-remote-local}} | ||
| + | |||
| + | ==Erläuterung== | ||
| + | :-f lässt den Prozess im Hintergrund laufen | ||
| + | :-g erlaubt remoteusern den lokal geöffneten ssh tunnel zu benutzen | ||
| + | :-p gibt den Port an über den sich SSH verbinden soll | ||
| + | :-N ist eine nützliche Option um das öffnen einer remoteshell zu unterbinden | ||
| + | :-R leitet den Port vom remoteserver auf localhost weiter | ||
| + | :-L leitet den Port von localhost auf remoteserver weiter | ||
Aktuelle Version vom 11. Juli 2021, 17:01 Uhr
Verbindungsaufbau vereinfacht
Server
Installation
- apt-get install ssh
Konfig Verzeichnis
/etc/ssh
Konfigurationsdatei
Beispiel
- cat /etc/ssh/sshd
Port 22 HostKey /etc/ssh/ssh_host_rsa_key HostKey /etc/ssh/ssh_host_ecdsa_key HostKey /etc/ssh/ssh_host_ed25519_key PermitRootLogin prohibit-password ChallengeResponseAuthentication no UsePAM yes X11Forwarding yes PrintMotd no AcceptEnv LANG LC_* Subsystem sftp /usr/lib/openssh/sftp-server PasswordAuthentication yes
start,stop,restart,status
- systemctl start ssh
- systemctl stop ssh
- systemctl status ssh
- systemctl restart ssh
Client
Konfigurations Verzeichnis
/etc/ssh
Heimat Verzeichnis
~/.ssh
remote login
- ssh harald@rechner
- ssh -l harald rechner
- ssh -p 22 -l harald rechner
Ausführen eines Programs auf einem anderem Rechner
- ssh harald@rechner date
- ssh harald@rechner pwd
- ssh harald@rechner ls -l
Secure copy
local to remote
file
- scp /etc/hosts harald@rechner:/tmp
directory
- scp -r /bin harald@rechner:/tmp
Schlüsselpaar erstellen
- ssh-keygen
Generating public/private rsa key pair. Enter file in which to save the key (/root/.ssh/id_rsa): Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in /root/.ssh/id_rsa. Your public key has been saved in /root/.ssh/id_rsa.pub. The key fingerprint is: SHA256:EuZ8a0Ovlq5ZdXXOsUUMH2pPT3NzD8k8bbfXkjq9nsg root@unaris The key's randomart image is: +---[RSA 2048]----+ | .+.| | o.=o| | o oB=@| | + . ..oX#| | + S . . o+B| | + + . o ..| | =.. o . | | +oo . o o | | o+o E.+ | +----[SHA256]-----+
Key zum Zielrechner übertragen
- ssh-copy-id harald@rechner
Login testen
- ssh harald@rechner
SSH Tunnel (Port Forwarding)
Local Port zu Remote Port Umleitung
alice port 9999 ---> bob port 8888
- ssh -4 -f -N bob@bob-host -L 9999:localhost:8888
Remote Port zu Local Port Umleitung
bob port 7777 ---> alice port 6666
- ssh -4 -f -N bob-host -R 7777:localhost:6666
Erläuterung
- -f lässt den Prozess im Hintergrund laufen
- -g erlaubt remoteusern den lokal geöffneten ssh tunnel zu benutzen
- -p gibt den Port an über den sich SSH verbinden soll
- -N ist eine nützliche Option um das öffnen einer remoteshell zu unterbinden
- -R leitet den Port vom remoteserver auf localhost weiter
- -L leitet den Port von localhost auf remoteserver weiter


