1.1 修改SSHD配置,禁止root遠程登錄
禁止登錄之前先穿甲一個可以遠程登錄的普通用戶,以免造成登錄不了的情況
[root@jhkj66 ~]# useradd yw001 #創建用戶 [root@jhkj66 ~]# passwd yw001 #設置密碼 Changing password for user yw001. New password: #輸入你的密碼 Retype new password: #確認密碼 passwd: all authentication tokens updated successfully. #設置成功
1.1.1 打開SSHD的配置文件
#vim /etc/ssh/sshd_config #查找“#PermitRootLogin yes”,將前面的“#”去掉,短尾“yes”改為“no”(不同版本可能區分大小寫),並保存文件。
1.1.2 修改完畢后,重啟sshd服務
service sshd restart #centos6系列 systemctl restart sshd #centos7系列
1.2 修改sshd默認端口
雖然更改端口無法在根本上抵御端口掃描,但是,可以在一定程度上提高防御。
1.2.1 打開sshd配置文件
#vi /etc/ssh/sshd_config #找到#Port 22字段刪掉#,將22改為其他不被使用的端口服務器端口最大可以開到65536
1.2.2 重啟sshd服務
#service sshd restart #centos6系列 #systemctl restart sshd #centos7系列
1.3 別忘了修改登陸工具那的端口設置