Benutzer-Werkzeuge

Webseiten-Werkzeuge


en:howtos:ssh

Unterschiede

Hier werden die Unterschiede zwischen zwei Versionen angezeigt.

Link zu dieser Vergleichsansicht

Beide Seiten der vorigen RevisionVorhergehende Überarbeitung
Nächste Überarbeitung
Vorhergehende Überarbeitung
en:howtos:ssh [2022/02/18 08:32] – [Schritt 3: Eine Passwortabfrage pro Tag] morquaien:howtos:ssh [2022/02/18 08:40] (aktuell) – [Fazit: Beispiel einer .ssh/config] morquai
Zeile 94: Zeile 94:
  
 **Note: if you use PuTTY and openssh under Cygwin in parallel, you should look at using PAGEANT (PuTTY) and working with ssh-pageant (openssh under Cygwin). [[https://mplx.eu/tech/ssh-key-agents-linux-windows-cygwin|Here is a link to get started]] ** **Note: if you use PuTTY and openssh under Cygwin in parallel, you should look at using PAGEANT (PuTTY) and working with ssh-pageant (openssh under Cygwin). [[https://mplx.eu/tech/ssh-key-agents-linux-windows-cygwin|Here is a link to get started]] **
-==== Schritt 4: Den SSH Key auch von server.example.com aus benutzen ====+==== Step 4: Use the SSH key also from server.example.com ====
  
-Oft findet man eine ganze Serverlandschaft, auf der man sich anmelden kannWenn man erst einmal den öffentlichen Teil des SSH Keys auf allen Servern hinterlegt hatkann man sich vom Client aus auf jedem Server ohne weiteres Passwort anmeldenWenn man nun aber von einem zum anderen Server springen will, wird man wieder nach dem Passwort gefragt, denn der Agent läuft ja nur auf unserem ClientEine unverzeihliche Sünde ist es nun den Private Key auf die Server in der Domain example.com zu kopieren. \\ +Often you will find a whole server landscape on which you can registerOnce you have deposited the public part of the SSH key on all serversyou can log on to any server from the client without an additional passwordBut if you now want to jump from one server to the other, you will be asked for the password againbecause the agent only runs on our clientIt is now an unforgivable sin to copy the private key to the servers in the example.com domain. \\ 
-**Ein Private Key darf den Client NIEMALS verlassen.**\\ +**A private key must NEVER leave the client.**\\ 
-Natürlich hat openssh hier eine Lösung paratdenn der ssh-agent kann noch mehrDer Private Key kann in einer ganze Kette aufeinander folgende SSH Sessions benutzt werdenDer Schalter "-A" sorgt dafür, das der Private Key durch alle ssh Instanzen weiter gereicht wird:+Of course, openssh has a solution herebecause the ssh-agent can do even moreThe private key can be used in a whole chain of consecutive SSH sessionsThe "-A" switch ensures that the private key is passed on through all ssh instances:
   client: ssh -A server.example.com   client: ssh -A server.example.com
   server.example.com: ssh server2.example.com   server.example.com: ssh server2.example.com
-Auch der auf "server.example.com" abgesetzte ssh Befehl erforder kein Passwortder ssh-agent befriedigt die Anfrage des Private Keys problemlossofern mittels "ssh-copy-id" der öffentliche Schlüssel auf server2.example.com bereitgestellt wurdeDie Entsprechung in der .ssh/config lautet+The ssh command sent to "server.example.com" also does not require a passwordthe ssh-agent satisfies the request for the private key without any problemsprovided the public key was provided on server2.example.com using "ssh-copy-id"The equivalent in the .ssh/config is
   host *   host *
     ForwardAgent yes     ForwardAgent yes
-Und wieder etwas gelerntman kann für die Definitionen in der .ssh/config Wildcards ("*" und "?"verwendenAber AchtungEs werden alle Definitionen in allen Gruppen angewendet, auf die die Wildcards zutreffen. +And learned something againyou can use wildcards ("*" and "?"for the definitions in the .ssh/config. But be carefulAll definitions in all groups to which the wildcards apply are used
-   +==== Step 5: Use non-public services locally ==== 
-==== Schritt 5: nicht öffentliche Services lokal nutzen ==== +What do you mean with thatA web server runs on server.example.com, which cannot be reached from the Internet, but which we want to address on our clientA web server is addressed on port 80 (unencryptedor 443 (encrypted). However, this port is blocked by a firewallThe solution isport forwardingwhich is not a problem with openssh.
-Was ist damit gemeintAuf server.example.com läuft ein WebServerder aus dem Internet nicht erreichbar istden wir aber auf unserem Client ansprechen wollenEin WebServer wird auf Port 80 (unverschlüsseltoder 443 (verschlüsseltangesprochenDieser Port wird aber von einer Firewall geblocktDie Lösung lautetPort Forwardingwas mit openssh kein Problem ist+
   ssh -L 1234:localhost:443 server.example.com   ssh -L 1234:localhost:443 server.example.com
-Was will uns der Dichter damit sagenDie SSH Session wird überredet, auf dem Client den Port 1234 zu öffnen und jeglichen Traffic auf diesem Port an den Port 443 auf server.example.com ("localhost", aus dessen SichtweiterzuleitenIm Browser reicht nun die Eingabe von +What is the poet trying to tell usThe SSH session is persuaded to open port 1234 on the client and forward all traffic on that port to port 443 on server.example.com ("localhost", from his point of view). Entering in the browser is now sufficient
   https://localhost:1234   https://localhost:1234
-um den Webserver zu erreichen. \\+to reach the web server. \\
  
-Der Eintrag in der .ssh/config lautet +The entry in the .ssh/config is 
-  LocalForward    1234 localhost:443+  LocalForward 1234 localhost:443
  
-VerwirrendDas liegt an der Doppelnutzung von "localhost"Dieser Rechnername "localhost" bezieht sich immer auf den Rechner, auf dem er interpretiert wird. In dem SSH Command wird "localhost" aus Sicht von "server.example.com" interpretiertim Browserder ja auf dem Client läuftwird es natürlich als "Clientinterpretiert. \\ +ConfusingThis is due to the dual use of "localhost"This computer name "localhost" always refers to the computer on which it is interpreted. In the SSH command, "localhost" is interpreted from the point of view of "server.example.com", in the browserwhich runs on the clientit is of course interpreted as "client". \\ 
-Aber in der Serverlandschaft hinter server.example.com laufen mehrere WebServerfür jeden einzelnen ein Port Forwarding einzurichten ist wohl ein wenig aufwendigAber natürlich hat openssh alles zur HandWir richten uns einfach einen Socks Proxy einden wir im Browser eintragen und schon stehen alle WebServer mit einem einzigen Eintrag im SSH Command zur Verfügung.+But in the server landscape behind server.example.com there are several web servers runningand setting up port forwarding for each one is probably a bit time-consumingBut of course openssh has everything at handWe simply set up a socks proxywhich we enter in the browser and all web servers are available with a single entry in the SSH command.
   ssh -D 3128 server.example.com   ssh -D 3128 server.example.com
-Wie immer was es das schon. Nur noch im Browse die Proxy Einstellungen einstellen und die alle Webserverdie server.example.com erreichen kann, stehen zur VerfügungUnschön ist das Verhalten, wenn man Namen statt IP-Adressen benutztNormalerweise sprechen wir Webseiten nach dem Schema <hostname>.<domain> (z.B. www.google.de) anDer DNS nimmt uns die Arbeit ab, die Namen in IP Adressen zu übersetzenDa das DNS Protokoll auf UDP basiert, ssh aber nur TCP zur Verfügung stelltmüssen die Namen entweder im öffentlichen DNS auflösbar sein oder in der lokalen Hosts Datei gepflegt sein. \\ +As alwaysthat's it. Just set the proxy settings in the browser and all web servers that can reach server.example.com are availableThe behavior is unpleasant if you use names instead of IP addressesNormally we address websites according to the scheme <hostname>.<domain> (e.g. www.google.de). The DNS does the work for us to translate names into IP addressesSince the DNS protocol is based on UDP, but ssh only provides TCP, the names must either be resolvable in public DNS or maintained in the local hosts file. \\ 
-Ach jawie sieht denn der Eintrag in der .ssh/config aus+Oh yeswhat does the entry in .ssh/config look like
-  DynamicForward  3128+  DynamicForward 3128 
 +==== Conclusion: Example of a .ssh/config ====
  
- +  First of all the settings that should apply to all computers 
-==== Fazit: Beispiel einer .ssh/config ==== +  hosting 
- +    # ssh-agent should provide the private keys
-  Ersteinmal die Einstellungen, die für alle Rechner gelten sollen +
-  Host +
-    # ssh-agent soll die private Keys zur Verfügung stellen+
     ForwardAgent yes     ForwardAgent yes
-    # Bei Ungereimtheiten mit Host Keys wollen wir gefragt werden+    # If there are any inconsistencies with host keys, we want to be asked
     StrictHostKeyChecking ask     StrictHostKeyChecking ask
-    # den Wert mancher Variablen wollen wir mitschleppen, hier diejenigen+    # We want to carry the value of some variables with ushere those 
-    # die sich auf die Sprachumgebung beziehen+    # related to the locale
     SendEnv LANG LC_*     SendEnv LANG LC_*
-    # Wo steht nochmal unser Private Key+    # Where is our private key again
-    IdentityFile    ~/.ssh/rsakey +    IdentityFile ~/.ssh/rsakey 
-  # Nun zu Server.example.com +  # Now to Server.example.com 
-  # Da die für alle Hosts geltenden Einstellungen hier ebenfalls gültig sindbrauchen wir nur  +  # Since the settings that apply to all hosts are also valid herewe only need 
-  # anzugeben, was sich ändert oder was hinzukommt+  # indicate what changes or what is added
   Host Server.example.com   Host Server.example.com
-    # wie lautet unser Benutzename+    # what is our username
     User user     User user
-    # unser netter Socks 5 Proxy +    # our nice Socks 5 proxy 
-    DynamicForward  3128 +    DynamicForward 3128 
-    # Der lokale Forward um den Webserver auf server.example.com zu erreichen +    # The local forward to reach the web server on server.example.com 
-    # ist ja eigentlich unnötigdenn wir haben ja einen Dynamic Forward +    # is actually unnecessarybecause we have a dynamic forward 
-    LocalForward    1234 localhost:443 +    LocalForward 1234 localhost:443 
-  # Hier mal ein Beispiel für mehrere Server+  # Here is an example for multiple servers
   Host *.example.com   Host *.example.com
     User user     User user
  
-Die Grundlagen sind gelegt und die meisten Fragen beantwortetWeitergehende HowTo'zu SSH folgen.... +The basics have been laid and most questions have been answeredFurther HowTo'for SSH will follow....
-         +
en/howtos/ssh.1645173146.txt.gz · Zuletzt geändert: 2022/02/18 08:32 von morquai