SSH Client

Aus Xinux Wiki
Zur Navigation springen Zur Suche springen

Einloggen

xinux@orville:~$ ssh kit@server

The authenticity of host 'server (192.168.16.216)' can't be established.
ED25519 key fingerprint is SHA256:GOyaDogwsT3hrFwp3lEelZqiTQ6l3ORN+aSnzwo5Wdg.
This key is not known by any other names.
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added 'server' (ED25519) to the list of known hosts.
kit@server's password: *****
Linux server.it216.int 6.12.73+deb13-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.12.73-1 (2026-02-17) x86_64

The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
Last login: Thu Oct 23 11:26:23 2025 from 10.81.31.112
kit@server.it216.int:~$

Ausloggen

kit@server.it216.int:~$ exit

logout
Connection to server closed.

User Keys generieren

xinux@orville:~$ ssh-keygen

 Generating public/private ed25519 key pair.
 Enter file in which to save the key (/home/xinux/.ssh/id_ed25519): 
 Enter passphrase for "/home/xinux/.ssh/id_ed25519" (empty for no passphrase): 
 Enter same passphrase again: 
 Your identification has been saved in /home/xinux/.ssh/id_ed25519
 Your public key has been saved in /home/xinux/.ssh/id_ed25519.pub
 The key fingerprint is:
 SHA256:GgiLput73H6NERA15OBg/pTRYYMnHzEz4dgxRgxQcb0 xinux@orville
 The key's randomart image is:
 +--[ED25519 256]--+
 |   +oB@^=        |
 |  o o+%=O.       |
 |  .. ==+. .      |
 | . oo. o E       |
 |... ... S        |
 |o      +         |
 |. . . . +        |
 | . o . o .       |
 |ooo ...          |
 +----[SHA256]-----+

Öffentlicher Schlüsselübertragen

ssh-copy-id kit@server

/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/home/xinux/.ssh/id_ed25519.pub"

kit@server's password: ******

Number of key(s) added: 1 

Now try logging into the machine, with: "ssh 'kit@server'"
and check to make sure that only the key(s) you wanted were added.

xinux@orville:~$ ssh kit@server

Enter passphrase for key '/home/xinux/.ssh/id_ed25519': ******

SSH-Agent (Passphrase nur einmal eingeben)

Wer einen SSH-Schlüssel mit Passphrase verwendet, muss diese normalerweise bei jeder Verbindung neu eingeben. Der ssh-agent merkt sich die entschlüsselten Schlüssel für die Dauer der Sitzung.

Mit grafischer Oberfläche (GNOME, KDE, etc.)

Desktop-Umgebungen starten automatisch einen ssh-agent. Es reicht ein einmaliges: xinux@orville:~$ ssh-add ~/.ssh/id_ed25519

Enter passphrase for /home/xinux/.ssh/id_ed25519: ******
Identity added: /home/xinux/.ssh/id_ed25519 (xinux@orville)

Ab jetzt funktioniert ssh kit@server ohne Passphrase-Eingabe – bis zum nächsten Login.

Ohne grafische Oberfläche (Server, reines Terminal)

Hier startet kein Agent automatisch. Folgenden Block an das Ende der /etc/bash.bashrc anhängen:

#Existiert die Datei und ist ein »Socket«?
if [ ! -S ~/.ssh/ssh_auth_sock ]
then
  #eval wertet die Rückgabe nochmal aus
  eval $(ssh-agent) > /dev/null 2>&1
  #Ist das Verzeichnis vorhanden? Wenn nicht, wird es angelegt
  test -d ~/.ssh || mkdir ~/.ssh
  #Wir verlinken diesen Socket auf einen festen Pfad
  #Dieser lebt bis zum Neustart
  ln -sf "$SSH_AUTH_SOCK" ~/.ssh/ssh_auth_sock
fi
export SSH_AUTH_SOCK=~/.ssh/ssh_auth_sock

Danach den Schlüssel einmalig zum Agent hinzufügen: xinux@orville:~$ ssh-add ~/.ssh/id_ed25519

Enter passphrase for /home/xinux/.ssh/id_ed25519: ******
Identity added: /home/xinux/.ssh/id_ed25519 (xinux@orville)

Hinweis: Bei jedem Neustart muss ssh-add einmal erneut ausgeführt werden. Die Passphrase selbst wird dabei nicht gespeichert – das ist gewollt.