dropbear 負責hosts.allow 和hosts.deny?

dropbear 負責hosts.allow 和hosts.deny?

dropbear我在 Debian(實際上是 Raspbian)上作為 SSH 守護程式運行。我嘗試設定

# /etc/hosts.allow
dropbear:192.168.1.1
# my static ip from which I SSH connect to the device

# /etc/hosts.deny
ALL:ALL
# block all others

然後我重新啟動了整個裝置。我仍然可以從不同的 IP 位址甚至遠端透過 SSH 連接到設備。是我設定檔錯誤還是不dropbear支援這兩個檔案?

答案1

Dropbear 不包含對/etc/hosts.allow和 的任何支援/etc/hosts.deny。這些文件由TCP 包裝器庫 ( libwrap),Dropbear 不使用該庫。一些第三方軟體包修補了 Dropbear 以支援 TCP 包裝器,但 Debian 沒有。

您可以透過以下方式啟動 Dropbeartcpd獲得 TCP 包裝器支援。

/usr/sbin/tcpd /usr/sbin/dropbear -i

如果只想按 IP 位址過濾,可以使用 iptables 來完成。

iptables -A INPUT -p tcp ! --dport 22 -j DROP

答案2

嘗試:

# /etc/hosts.deny
sshd:ALL:spawn /bin/echo  the ip %h tried to access `/bin/date`>> /var/log/ssh.log

# /etc/hosts.allow
sshd:192.168.1.1

如果不起作用,請以這種方式使用 dropbear 重試。

# /etc/hosts.deny
dropear:ALL:spawn /bin/echo  the ip %h tried to access `/bin/date`>> /var/log/ssh.log

# /etc/hosts.allow
dropbear:192.168.1.1

並檢查 dropbear 是否支援 tcp/wrappers。

ldd /path/to/dropbear

尋找libwrap.so.0 → /lib/libwrap.so.0

相關內容