CentOS6.8 SSH連接失敗的深度排查指南
服務(wù)運(yùn)行狀態(tài)驗(yàn)證
執(zhí)行以下命令確認(rèn)SSHD服務(wù)是否正常運(yùn)行:
service sshd status
service sshd restart # 重啟服務(wù)
chkconfig sshd on # 設(shè)置開機(jī)啟動(dòng)
防火墻策略檢查
排查iptables是否開放22端口:
iptables -L -n | grep 22
service iptables stop # 臨時(shí)關(guān)閉防火墻測(cè)試
配置文件參數(shù)修正
檢查/etc/ssh/sshd_config
關(guān)鍵配置項(xiàng):
Port 22
PermitRootLogin yes
AllowUsers your_username
端口占用檢測(cè)
通過netstat驗(yàn)證22端口監(jiān)聽狀態(tài):
netstat -tulnp | grep 22
lsof -i :22
網(wǎng)絡(luò)連通性測(cè)試
多維度驗(yàn)證網(wǎng)絡(luò)可達(dá)性:
ping server_ip
telnet server_ip 22
traceroute server_ip
SELinux安全模塊影響
臨時(shí)禁用SELinux進(jìn)行測(cè)試:
setenforce 0
getenforce # 驗(yàn)證狀態(tài)
系統(tǒng)日志分析
審查/var/log/secure
日志文件:
tail -f /var/log/secure
grep 'sshd' /var/log/secure
主機(jī)訪問控制驗(yàn)證
檢查hosts訪問限制文件:
/etc/hosts.allow
/etc/hosts.deny