Hier werden die Unterschiede zwischen zwei Versionen angezeigt.
Beide Seiten der vorigen RevisionVorhergehende ÜberarbeitungNächste Überarbeitung | Vorhergehende Überarbeitung | ||
en:howtos:ssh [2022/02/18 08:31] – [Schritt 2: geht das auch ohne Passwort] morquai | en:howtos:ssh [2022/02/18 08:40] (aktuell) – [Fazit: Beispiel einer .ssh/config] morquai | ||
---|---|---|---|
Zeile 74: | Zeile 74: | ||
IdentityFile ~/ | IdentityFile ~/ | ||
We have deactivated the server' | We have deactivated the server' | ||
- | ==== Schritt | + | ==== Step 3: One password request per day ==== |
- | Die openssh | + | The openssh |
- | ssh-agent | + | ssh agent |
SSH_AUTH_SOCK=/ | SSH_AUTH_SOCK=/ | ||
SSH_AGENT_PID=10682402; | SSH_AGENT_PID=10682402; | ||
echo Agent pid 10682402; | echo Agent pid 10682402; | ||
- | Damit ist der Agent gestartet und die Befehle, die eine Benutzung ermöglichen, | + | The agent is now started and the commands that enable use are issued. The agent stays active until the next reboot, so we can write the commands to a file and then run them in the current shell. Let's name the file ~/ |
SSH_AUTH_SOCK=/ | SSH_AUTH_SOCK=/ | ||
SSH_AGENT_PID=10682402; | SSH_AGENT_PID=10682402; | ||
echo Agent pid 10682402; | echo Agent pid 10682402; | ||
- | Und nun die Ausführung, der Punkt am Anfang signalisiert, | + | And now the execution, the dot at the beginning signals that the script is executed |
. ~/ | . ~/ | ||
- | Nachdem der Agent gestartet wurde und die Benutzung eingerichtet ist, müssen wir nun dem Agenten den Private Key zur Verfügung stellen | + | After the agent has been started and the use has been set up, we now have to provide the agent with the private key |
ssh-add ~/ | ssh-add ~/ | ||
- | Der Agent fordert uns auf die Passphrase einzugeben und kann nun die Aufgabe, den Private Key bei Bedarf zur Verfügung zu stellen, übernehmen. Die Anmeldung kann nun ohne jede Passwort Abfrage gemacht werden. | + | The agent asks us to enter the passphrase and can now take over the task of providing the private key if required. The registration can now be made without any password query. |
ssh server.example.com | ssh server.example.com | ||
- | Geschafft. die Passworteingabe ist ab nun nicht mehr erforderlich. Wir müssen nur nach einen Reboot daran denken den Agenten erneut zu starten und die ausgegebenen Befehle in die Datei ~/ | + | Made it. from now on it is no longer necessary to enter a password. We only have to remember to start the agent again after a reboot and write the issued commands to the ~/ |
- | Wenn wir eine neue Shell starten muss natürlich auch hier die ~/ | + | Of course, if we start a new shell, |
- | **Hinweis: wer PuTTY und openssh | + | **Note: if you use PuTTY and openssh |
+ | ==== Step 4: Use the SSH key also from server.example.com ==== | ||
- | ==== Schritt 4: Den SSH Key auch von server.example.com aus benutzen ==== | + | Often you will find a whole server |
- | + | **A private key must NEVER leave the client.**\\ | |
- | Oft findet man eine ganze Serverlandschaft, auf der man sich anmelden kann. Wenn man erst einmal den öffentlichen Teil des SSH Keys auf allen Servern hinterlegt hat, kann man sich vom Client aus auf jedem Server ohne weiteres Passwort anmelden. Wenn man nun aber von einem zum anderen Server springen | + | Of course, |
- | **Ein Private Key darf den Client NIEMALS verlassen.**\\ | + | |
- | Natürlich hat openssh | + | |
client: ssh -A server.example.com | client: ssh -A server.example.com | ||
server.example.com: | server.example.com: | ||
- | Auch der auf " | + | The ssh command sent to " |
host * | host * | ||
ForwardAgent yes | ForwardAgent yes | ||
- | Und wieder etwas gelernt, man kann für die Definitionen in der .ssh/config Wildcards | + | And learned something again, you can use wildcards |
- | | + | ==== Step 5: Use non-public services locally |
- | ==== Schritt | + | What do you mean with that? A web server runs on server.example.com, |
- | Was ist damit gemeint? Auf server.example.com | + | |
ssh -L 1234: | ssh -L 1234: | ||
- | Was will uns der Dichter damit sagen? Die 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 (" | + | What is the poet trying to tell us? The 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 (" |
https:// | https:// | ||
- | um den Webserver zu erreichen. \\ | + | to reach the web server. \\ |
- | Der Eintrag | + | The entry in the .ssh/ |
- | LocalForward | + | LocalForward 1234 localhost: |
- | Verwirrend? Das liegt an der Doppelnutzung von " | + | Confusing? This is due to the dual use of " |
- | Aber in der Serverlandschaft hinter | + | But in the server landscape behind |
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 Webserver, die server.example.com | + | As always, that's it. Just set the proxy settings in the browser and all web servers that can reach server.example.com |
- | Ach ja, wie sieht denn der Eintrag | + | Oh yes, what does the entry in .ssh/ |
- | DynamicForward | + | DynamicForward 3128 |
+ | ==== Conclusion: Example of a .ssh/config ==== | ||
- | + | | |
- | ==== Fazit: Beispiel einer .ssh/config ==== | + | |
- | + | # ssh-agent | |
- | | + | |
- | | + | |
- | # ssh-agent | + | |
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, | + | # We want to carry the value of some variables with us, here 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 | + | IdentityFile ~/ |
- | # Nun zu Server.example.com | + | # Now to Server.example.com |
- | # Da die für alle Hosts geltenden Einstellungen hier ebenfalls gültig sind, brauchen wir nur | + | # Since the settings that apply to all hosts are also valid here, we 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 | + | # our nice Socks 5 proxy |
- | DynamicForward | + | DynamicForward 3128 |
- | # Der lokale Forward um den Webserver auf server.example.com | + | # The local forward to reach the web server on server.example.com |
- | # ist ja eigentlich unnötig, denn wir haben ja einen Dynamic Forward | + | # is actually unnecessary, because we have a dynamic forward |
- | LocalForward | + | LocalForward 1234 localhost: |
- | # 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 beantwortet. Weitergehende | + | The basics have been laid and most questions have been answered. Further |
- | + |