1. Pasang Paket OpenSSH
Jalankan perintah berikut di Ubuntu:
$ sudo apt update
$ sudo apt install -y openssh-server openssh-client
$ sudo systemctl enable ssh --now
$ sudo systemctl status ssh
2. Ubah Port SSH
Edit konfigurasi SSH menggunakan VIM:
$ sudo vim /etc/ssh/sshd_config
Cari baris:
#Port 22
Ubah menjadi:
Port 2802
Simpan lalu restart layanan SSH:
$ sudo systemctl restart ssh
3. Buat User Baru
$ sudo adduser genz
Login dari laptop:
$ ssh -p 2802 genz@ip-ubuntu
4. Nonaktifkan Akses Root
Edit file konfigurasi:
$ sudo vim /etc/ssh/sshd_config
Ubah baris:
PermitRootLogin no
$ sudo systemctl restart ssh
5. Autentikasi Menggunakan SSH Key
Buat SSH key di laptop:
$ ssh-keygen -t rsa -C 4096
Copy kunci publik ke server:
$ ssh-copy-id -p 2802 genz@ip-ubuntu
Edit kembali konfigurasi SSH di server:
#PubkeyAuthentication yes #sebelum dirubahPasswordAuthentication no #sesudah dirubah
$ sudo systemctl restart ssh
6. Tes Akses
$ ssh -p 2802 genz@ip-ubuntu
$ ssh -p 2802 root@ip-ubuntu
✅ Jika berhasil, login akan langsung menggunakan SSH Key tanpa password.

Komentar
Posting Komentar