Masalahnya
Server gagal masuk melalui ssh dengan kesalahan di bawah ini.
Dari klien ssh:
$ ssh -vvv root@10.131.12.10 OpenSSH_7.6p1, LibreSSL 2.6.2 debug1: Reading configuration data /etc/ssh/ssh_config debug1: /etc/ssh/ssh_config line 48: Applying options for * debug2: ssh_connect_direct: needpriv 0 debug1: Connecting to 10.131.12.10 port 22. debug1: Connection established. debug1: key_load_public: No such file or directory debug1: identity file /Users/yaozhenqiang/.ssh/id_rsa type -1 debug1: key_load_public: No such file or directory debug1: identity file /Users/yaozhenqiang/.ssh/id_rsa-cert type -1 debug1: key_load_public: No such file or directory debug1: identity file /Users/yaozhenqiang/.ssh/id_dsa type -1 debug1: key_load_public: No such file or directory debug1: identity file /Users/yaozhenqiang/.ssh/id_dsa-cert type -1 debug1: key_load_public: No such file or directory debug1: identity file /Users/yaozhenqiang/.ssh/id_ecdsa type -1 debug1: key_load_public: No such file or directory debug1: identity file /Users/yaozhenqiang/.ssh/id_ecdsa-cert type -1 debug1: key_load_public: No such file or directory debug1: identity file /Users/yaozhenqiang/.ssh/id_ed25519 type -1 debug1: key_load_public: No such file or directory debug1: identity file /Users/yaozhenqiang/.ssh/id_ed25519-cert type -1 debug1: Local version string SSH-2.0-OpenSSH_7.6 ssh_exchange_identification: read: Connection reset by peer
Dari server ssh:
# /usr/sbin/sshd -D -ddd ....snip.... debug1: Bind to port 22 on ::. Server listening on :: port 22. debug3: fd 5 is not O_NONBLOCK debug1: Server will not fork when running in debugging mode. debug3: send_rexec_state: entering fd = 8 config len 583 debug3: ssh_msg_send: type 0 debug3: send_rexec_state: done debug1: rexec start in 5 out 5 newsock 5 pipe -1 sock 8 debug1: inetd sockets after dupping: 3, 3 debug1: Connection refused by tcp wrapper
Solusinya
koneksi ssh ditolak oleh pembungkus tcp. Untuk menentukan apakah mesin klien diizinkan untuk terhubung ke SSH, pembungkus TCP merujuk dua file berikut:
- /etc/hosts.deny
- /etc/hosts.allow
Ikuti langkah-langkah di bawah ini untuk menentukan alamat IP klien ssh mana yang ditolak oleh pembungkus TCP:
1. Komentari semua baris di /etc/hosts.deny dan /etc/hosts.allow
2. Sekarang login ssh seharusnya berfungsi normal:
$ ssh root@10.131.12.10 root@10.131.12.10's password: Last login: Fri Mar 16 11:14:44 2018 from server1
3. Buka server ssh, buka /var/log/secure dan arahkan ke pesan di sekitar stempel waktu “Login terakhir:Jum 16 Mar 11:14:44 2018” yang ditampilkan di langkah 2, maka kita bisa mendapatkan alamat IP klien ssh yang sebelumnya ditolak oleh pembungkus TCP.
4. Kembalikan /etc/hosts.deny dan /etc/hosts.allow dan tambahkan baris di bawah ini di /etc/hosts.allow (Katakanlah, 192.168.1.2 adalah alamat IP yang kita dapatkan di langkah 3)
# vi /etc/hosts.allow sshd:192.168.1.2:allow
5. Verifikasi apakah login ssh berfungsi.