2007年7月10日 星期二

SSH 設定小秘訣

A. 常常用ssh連機器,但幾分鐘沒動作後畫面就當掉了...

Linux / FreeBSD 解決方法:
1. 修改 /etc/ssh/sshd_config
ClientAliveInterval 300 <-- 5 分鐘

這樣就不會 timeout 了。

-----------------------------------------
B. 如何保護SSH的登入,只開放給允許的特定IP
# vi /etc/hosts.allow
sshd: 192.168.0.1, 192.168.0.2, 192.168.0.3, 192.168.0.4, 192.168.0.5: allow

# vi /etc/hosts.deny
sshd : ALL : spawn (/bin/echo Security notice from host `/bin/hostname`; \
/bin/echo; /usr/sbin/safe_finger @%h ) | \
/bin/mail -s "%d -%h security" root@localhost & \
: twist ( /bin/echo -e "\n\nWARNING connectin not allowed.". )

沒有留言: