Show pageOld revisionsBacklinksBack to top This page is read only. You can view the source, but not change it. Ask your administrator if you think this is wrong. {{indexmenu_n>0010}} ====== Setup dan Manajemen SSH Key ====== Panduan membuat SSH Key, jenis-jenis SSH Key, dan cara memasang public key ke server. ===== SSH Key Overview ===== SSH Key digunakan untuk autentikasi ke server tanpa menggunakan password. SSH Key terdiri dari: * **Private Key** : Disimpan lokal, jangan dibagikan. * **Public Key** : Dikirim ke server untuk autentikasi. ===== Generate SSH Key ===== Generate SSH Key menggunakan command ''ssh-keygen''. ===== Default SSH Key (ED25519) ===== ED25519 adalah tipe key modern yang direkomendasikan. <code bash> ssh-keygen -t ed25519 </code> Keterangan: * ''-t ed25519'' => menggunakan algoritma ED25519. * Default file: * Private Key : ''~/.ssh/id_ed25519'' * Public Key : ''~/.ssh/id_ed25519.pub'' ===== RSA SSH Key ===== RSA digunakan untuk kompatibilitas dengan sistem lama. <code bash> ssh-keygen -t rsa -b 4096 </code> Keterangan: * ''-t rsa'' => menggunakan algoritma RSA. * ''-b 4096'' => ukuran key 4096 bit. ===== ECDSA SSH Key ===== ECDSA adalah algoritma berbasis elliptic curve. <code bash> ssh-keygen -t ecdsa -b 521 </code> Keterangan: * ''-t ecdsa'' => menggunakan ECDSA. * ''-b 521'' => ukuran curve. ===== Generate SSH Key Dengan Nama File Custom ===== Gunakan nama file berbeda jika memiliki banyak SSH Key. <code bash> ssh-keygen -t ed25519 -f ~/.ssh/server-prod </code> Hasil: <code> ~/.ssh/server-prod ~/.ssh/server-prod.pub </code> ===== Generate SSH Key Dengan Comment ===== Menambahkan identitas pada public key. <code bash> ssh-keygen -t ed25519 -C "ilyasa@hostname" </code> Contoh hasil: <code> ssh-ed25519 AAAAC3... ilyasa@hostname </code> ===== Melihat SSH Public Key ===== Public key dapat dilihat menggunakan command: <code bash> cat ~/.ssh/id_ed25519.pub </code> atau: <code bash> cat ~/.ssh/id_rsa.pub </code> ===== Copy SSH Public Key Ke Server ===== ===== Menggunakan ssh-copy-id ===== Cara paling mudah untuk memasang public key ke server. <code bash> ssh-copy-id ilyasa@server-ip </code> Contoh: <code bash> ssh-copy-id ilyasa@192.168.1.10 </code> Keterangan: * Public key akan ditambahkan ke: * ''~/.ssh/authorized_keys'' ===== Copy SSH Key Dengan Port Custom ===== Jika SSH menggunakan port selain 22. <code bash> ssh-copy-id -p 2222 ilyasa@server-ip </code> ===== Manual Copy SSH Public Key ===== Jika ''ssh-copy-id'' tidak tersedia. Di client: <code bash> cat ~/.ssh/id_ed25519.pub </code> Copy hasil output. Di server: <code bash> mkdir -p /home/ilyasa/.ssh </code> Buat folder SSH. <code bash> nano /home/ilyasa/.ssh/authorized_keys </code> Paste public key. Set permission: <code bash> chmod 700 /home/ilyasa/.ssh chmod 600 /home/ilyasa/.ssh/authorized_keys </code> ===== Login Menggunakan SSH Key ===== Gunakan private key: <code bash> ssh ilyasa@server-ip </code> Dengan file key custom: <code bash> ssh -i ~/.ssh/server-prod ilyasa@server-ip </code> ===== SSH Agent ===== SSH Agent menyimpan private key di memory agar tidak perlu memasukkan passphrase berulang. Start SSH Agent: <code bash> eval "$(ssh-agent -s)" </code> Tambah SSH Key: <code bash> ssh-add ~/.ssh/id_ed25519 </code> Melihat key yang aktif: <code bash> ssh-add -l </code> ===== SSH Config File ===== Membuat shortcut koneksi SSH. Edit file: <code bash> nano ~/.ssh/config </code> Contoh: <code ssh> Host server-prod HostName 192.168.1.10 User ilyasa IdentityFile ~/.ssh/server-prod </code> Login: <code bash> ssh server-prod </code> ===== Backup SSH Key ===== Backup folder SSH: <code bash> cp -r ~/.ssh ~/ssh-backup </code> File penting: <code> ~/.ssh/id_ed25519 ~/.ssh/id_ed25519.pub ~/.ssh/config </code> ===== Permission SSH Key ===== Private key harus memiliki permission aman. <code bash> chmod 600 ~/.ssh/id_ed25519 </code> Folder SSH: <code bash> chmod 700 ~/.ssh </code> ===== Troubleshooting ===== Cek koneksi SSH dengan mode debug: <code bash> ssh -v ilyasa@server-ip </code> Debug lebih detail: <code bash> ssh -vvv ilyasa@server-ip </code> Cek authorized key server: <code bash> cat /home/ilyasa/.ssh/authorized_keys </code> ===== Rekomendasi ===== Gunakan: * ED25519 => pilihan utama untuk server modern. * RSA 4096 => untuk kompatibilitas sistem lama. * Jangan pernah membagikan private key. * Simpan backup private key di tempat aman. system/linux/ssh/ssh-keygen.txt Last modified: 2026/10/02 06:03by ilyasa