問:為什么用telnet/ftp登錄時特別慢,而登錄進(jìn)去后又正常呢?
答:這是因為telnetd/ftpd是用tcpd來啟動的,而tcpd要進(jìn)行安全性檢查,而它使用反向名字解析。
你可以把客戶機(jī)的IP地址/名字加到/etc/hosts中或加到DNS里。
另一種辦法是取消tcpd(不推薦),修改/etc/inetd.conf
將原來的:
ftp stream tcp nowait root /usr/sbin/tcpd in.ftpd -l -a
改為:
ftp stream tcp nowait root /usr/sbin/in.ftpd in.ftpd -l -a
原來的:
telnet stream tcp nowait root /usr/sbin/tcpd in.telnetd
改為: telnet stream tcp nowait root /usr/sbin/in.telnetd in.telnetd
改完之后用killall -HUP inetd即可生效。
問:如何禁止某個用戶的telnet功能,同時它有ftp功能?
答:假設(shè)你想把用戶ftponly的telnet關(guān)掉,
1)寫一個shell script /bin/ftponly:
#!/bin/sh
/bin/cat << XX
You can only use FTP on this computer,
but you may not use this account to login.
Connection will be closed in 10 seconds.
XX
/usr/bin/sleep 10
#end of ftponly
這里的XX是個標(biāo)志,當(dāng)ftponly試圖telnet的時候,屏幕上將顯示兩個XX之間的內(nèi)容,
然后10秒以后切斷connect。注:還應(yīng)該用trap來屏蔽鍵盤中斷吧!否則人家用Ctrl-Z......
2)把用戶ftponly的shell設(shè)置成/bin/ftponly:到passwd文件,找到對應(yīng)于ftponly的那行:
ftponly:......:/home/ftponly:/bin/bash
把最后的/bin/bash改為/bin/ftponly.
3)把 /bin/ftponly 加入到 /etc/shells
/bin/bash
/bin/tcsh
/bin/csh
/bin/ash
/bin/zsh
/bin/ftponly
就行了。
問:如何允許root用戶遠(yuǎn)程登錄?
答:編輯/etc/securetty,加上ttyp2,ttyp3等。
注意,有嚴(yán)重的安全性問題!
最好是用ssh(安全的shell)加su/sudo,而且用xterm的Secure Keyboard來做遠(yuǎn)程管理。
問:怎么樣做到限時登錄?
答:自己寫三個shell程序,調(diào)用at和系統(tǒng)維護(hù)功能:
1. 在指定的時間執(zhí)行該shell,在/etc下生成一名為nologin的文件,如:
vi /sbin/login.denied
echo " Login Denied " > /etc/nologin
chmod 700 login.denied
2. 在指定的時間執(zhí)行該shell,刪除/etc/下的nologin文件,如:
vi /sbin/login.allowed
if [ -f /etc/nologin ]; then
rm /etc/nologin
fi
chmod 700 login.allowed
3. 編寫一個限制時間的shell,如:
vi /sbin/security
if [ -f /sbin/login.denied ]; then
at -f /sbin/login.denid 22:00
fi
if [ -f /sbin/login.allowed ]; then
at -f /sbin/login.allowed 8:00
if
此種設(shè)置的功能是:從晚上10:00到第二天早上8:00靜止非root擁護(hù)登錄,顯示為系統(tǒng)維護(hù)狀態(tài)。
另外,還需對root用戶的登路終端進(jìn)行限制,最好設(shè)置在console。在RedHat 5.0下
在 /etc/security/access.conf中配置:
-:root:ALL EXCEPT console就可以了。
注:還要參考/etc/securetty里的設(shè)置吧!