ssh Verbindung ohne Login (Linux)

Antworten
Benutzeravatar
benny
Forum Junkie
Beiträge: 463
Registriert: 11.06.2016 - 11:51
Hat sich bedankt: 11 Mal
Geschlecht:

ssh Verbindung ohne Login (Linux)

Beitrag von benny »

Ein neues Schlüsselpaar auf der lokalen Maschine erzeugen: (die Standarteinstellungen sollten genügen)

Code: Alles auswählen

~$ ssh-keygen
Generating public/private rsa key pair.                                                                                                        
Enter file in which to save the key (/home/user/.ssh/id_rsa): 
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in /home/user/.ssh/id_rsa.
Your public key has been saved in /home/user/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:Ng60JoqFM9jLIgbggzZTGFfgkjnhuohzguFrtfv698hnHuhnjlk benny@SuckboxM
The key's randomart image is:
+---[RSA 2048]----+
|  +    .. .  . . |
|    E.    .    o.|
|      .   . * + +|
|.o   . .   + * ..|
|* = o + EE. . =  |
| O --  +   . +   |
|. + ..  = . . .  |
|   .  =  =   .   |
|    o=.o  .      |
+----[SHA256]-----+
Den Schlüssel auf die entfernte Maschine kopieren: (Das Passwort wird ein letztes mal gebraucht)

Code: Alles auswählen

~$ ssh-copy-id root@192.168.0.1
/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/home/user/.ssh/id_rsa.pub"
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys
root@192.168.0.1's password: 

Number of key(s) added: 1

Now try logging into the machine, with:   "ssh 'root@192.168.0.1'"
and check to make sure that only the key(s) you wanted were added.
Ab jetzt kann man sich einfach so ohne Passwort einloggen

Code: Alles auswählen

~$ ssh root@192.168.0.1
(Alle hier angezeigten Keys und "Bilder" sind natürlich nicht in Benutzung. ;) )

Bei einem OpenWRT (z. B. Router) muss man den öffentlichen Schlüssel noch in der Weboberfläche hochladen.
Die Datei id_rsa.pub (zu finden unter /home/user/.ssh/ ) muss in einem Editor geöffnet werden und der Inhalt dann in die Eingabebox für die ssh-keys kopiert werden. (Unter System --> Administration)
Bis dann,
benny

PS: Ich werde in Zukunft keinen Support mehr per PN leisten. Bitte eröffnet ein Thema im Hilfebereich, oder wo auch immer eure Fragen hin passen.
Antworten