This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm whether you accept or reject these cookies being set.

A cookie will be stored in your browser regardless of choice to prevent you being asked this question again. You will be able to change your cookie settings at any time using the link in the footer.

Zweites SSH-Schlüsselpaar zur SSH-Authentifizierung erstellen
#1
Erster Arbeitsschritt:

Einen neuen Ordner mit Namen .ssh-2 Lokal (Client) im Home-Vezeichnis erstellen:

mkdir .ssh-2

User@Kiste:~$ ssh-keygen -t rsa -b 4096

Generating public/private rsa key pair.

Angabe für neuen Ordner mit Namen .ssh-2:

Enter file in which to save the key (/home/username/.ssh/id_rsa): /home/username/.ssh-2/id_rsa
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/username/.ssh-2/id_rsa.
Your public key has been saved in /home/username/.ssh-2/id_rsa.pub.
The key fingerprint is:
SHA256:fingerprint username@kiste
The key's randomart image is:
+---[RSA 4096]----+


Auf den Server wechseln und Ordner erstellen:

User@Kiste:~$ mkdir .ssh
User@Kiste:~$ ls -al

drwxrwxr-x 2 Username Username 4096 Feb  1 12:07 .ssh

Diesen Ordner .ssh auf 700 setzen:

User@Kiste:~$ chmod 700 .ssh

User@Kiste:~$ ls -al

drwx------ 2 benutzer benuergr 4096 Feb  1 12:07 .ssh


Schlüssel vom Client auf den Server übertragen:


cd .ssh-2

User@Kiste:~/.ssh-2$ ssh-copy-id -i id_rsa.pub server@IP-Adresse -pPortangabe
/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "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
Benutzer@IP-Adresse's password:

Number of key(s) added: 1

Now try logging into the machine, with:  "ssh -p 'Port' 'Benutzer@IP-Adresse'"
and check to make sure that only the key(s) you wanted were added.


Überprüfung auf dem Server:

Benutzer@Server:~/.ssh$ ls

authorized_keys

Änderung der sshd_config:

sudo nano /etc/ssh/sshd_config

PasswordAuthentication no

sudo reboot

Fertig!

Eine Fehlkonfiguration der SSH Public-Key Authentifizierung könnte Ihnen den Zugang zum Server komplett sperren.

Bei bereits kompromittierten Server und Client-Rechnern ist diese Maßnahme von vornherein als sinnlos einzustufen.

Sie haben es selbst zu verantworten.
All done!
Zitieren


Gehe zu:


Benutzer, die gerade dieses Thema anschauen: 1 Gast/Gäste