Selain menggunakan username dan password untuk ssh, kita juga dapat menggunakan ssh keygen.
Langkah Pertama buat public key dan private key menggunakan ssh-keygen.
akhal@base:~$ ssh-keygen Generating public/private rsa key pair. Enter file in which to save the key (/home/akhal/.ssh/id_rsa): Created directory '/home/akhal/.ssh'. Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in /home/akhal/.ssh/id_rsa Your public key has been saved in /home/akhal/.ssh/id_rsa.pub The key fingerprint is: SHA256:DrejC3fKrrtftkZds3boNhn16SQEywyy8BO+m66vzEdRBxEI akhal@base The key's randomart image is: +---[RSA 3072]----+ |+E.o+o.o | |.+o oo. o | |o... o o . | | +...o*oo | |. = =ooOS. | | = o o+ = | |o o .o | |o+ .o. | |B=o o+. | +----[SHA256]-----+
Langkah kedua copy public key ke remote-host dengan menggunakan ssh-copy-id.
akhal@base:~$ ssh-copy-id -i ~/.ssh/id_rsa.pub remote-host akhal@remote-host's password: Now try logging into the machine, with "ssh 'remote-host'", and check in: .ssh/authorized_keys to make sure we haven't added extra keys that you weren't expecting.
Langkah terakhir login remote-host tanpa memasukkkan password.
akhal@base:~$ ssh akhal@remote-host Last login: Sun Nov 24 13:33:33 2021 from 192.168.1.10 [Note: SSH tidak meminta password untuk login] akhal@remote-host$ [Note: Sekarang Anda sudah berpindah ke remote-host]
Recent Comments