Şifre Sormadan SSH ile bağlanma

Linux Yazıları06/03/2019


SSH ile Linux serverlara bağlanırken şifre sormaması için...

Client Makinede

user@clientPc:~$ ssh-keygen -t rsa
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:b44x8h3HxPmtDRuHx123456789R1LTHJux5BTHD21kM user@clientPc

Client makineden Server'a bağlanıp .ssh klasörü oluşturulur.

user@clientPc:~$ ssh root@serverPc mkdir -p .ssh
root@serverPc's password:

Client makinede oluşturduğumuz public key dosyası, server'ın ".ssh/authorized_keys" dosyasına yazılır.

user@clientPc:~$ cat .ssh/id_rsa.pub | ssh root@serverPc 'cat >> .ssh/authorized_keys'
root@serverPc's password:

Artık clientPc'den serverPc'ya bağlanmak istediğimizde şifre sormayacaktır.

user@clientPc:~$ ssh root@serverPc

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: Tue Mar  5 07:16:28 2019 from clientPc
root@serverPc:~#