DEV Community

Cover image for Cara Menggunakan SSH Config File (~/.ssh/config)
fixploit03
fixploit03

Posted on

Cara Menggunakan SSH Config File (~/.ssh/config)

Apa itu SSH Config File?

Daripada ketik panjang setiap konek ke server:

ssh -p 2222 -i <path_key> <user>@<ip_server>
Enter fullscreen mode Exit fullscreen mode

Dengan SSH Config File, cukup ketik:

ssh <alias>
Enter fullscreen mode Exit fullscreen mode

1. Buat file config:

mkdir -p ~/.ssh && touch ~/.ssh/config
Enter fullscreen mode Exit fullscreen mode

2. Edit file config:

nano ~/.ssh/config
Enter fullscreen mode Exit fullscreen mode

3. Tambahkan konfigurasi server:

Host <alias>
    HostName <ip_server>
    User <user>
    Port <port_ssh>
    IdentityFile <path_key>
Enter fullscreen mode Exit fullscreen mode

Contoh:

Host ubuntu-server-26-04
    HostName 192.168.1.10
    User fixploit03
    Port 2222
    IdentityFile ~/.ssh/id_ed25519
Enter fullscreen mode Exit fullscreen mode

4. Atur permission file config:

chmod 600 ~/.ssh/config
Enter fullscreen mode Exit fullscreen mode

5. Tes koneksi:

ssh <alias>
Enter fullscreen mode Exit fullscreen mode


Kalau ada pertanyaan, silakan tanyakan di kolom komentar :)

Top comments (0)