標籤:
安裝SSH
yum install ssh
啟動SSH
service sshd start
設定開機運行
chkconfig sshd on
相關設定檔修改
[root@sample ~]# vi /etc/ssh/sshd_config ← 用vi開啟SSH的設定檔
#Protocol 2,1 ← 找到此行將行頭“#”刪除,再將行末的“,1”刪除,只允許SSH2方式的串連
↓
Protocol 2 ← 修改後變為此狀態,僅使用SSH2
#ServerKeyBits 768 ← 找到這一行,將行首的“#”去掉,並將768改為1024
↓
ServerKeyBits 1024 ← 修改後變為此狀態,將ServerKey強度改為1024位元
#PermitRootLogin yes ← 找到這一行,將行首的“#”去掉,並將yes改為no
↓
PermitRootLogin no ← 修改後變為此狀態,不允許用root進行登入
#PasswordAuthentication yes ← 找到這一行,將yes改為no
↓
PasswordAuthentication no ← 修改後變為此狀態,不允許密碼方式的登入
#PermitEmptyPasswords no ← 找到此行將行頭的“#”刪除,不允許空密碼登入
↓
PermitEmptyPasswords no ← 修改後變為此狀態,禁止空密碼進行登入
因為我們只想讓SSH服務為管理系統提供方便,所以在不通過外網遠端管理系統的情況下,只允許內網用戶端通過SSH登入到伺服器,以最大限度減少不安全因素。設定方法如下:
[root@sample ~]# vi /etc/hosts.deny ← 修改屏蔽規則,在文尾添加相應行
#
# hosts.deny This file describes the names of the hosts which are
# *not* allowed to use the local INET services, as decided
# by the ‘/usr/sbin/tcpd’ server.
#
# The portmap line is redundant, but it is left to remind you that
# the new secure portmap uses hosts.deny and hosts.allow. In particular
# you should know that NFS uses portmap!
sshd: ALL ← 添加這一行,屏蔽來自所有的SSH串連請求
[root@sample ~]# vi /etc/hosts.allow ← 修改允許規則,在文尾添加相應行
#
# hosts.allow This file describes the names of the hosts which are
# allowed to use the local INET services, as decided
# by the ‘/usr/sbin/tcpd’ server.
#
sshd: 192.168.0. ← 添加這一行,只允許來自內網的SSH串連請求
注意:hosts.deny 和hosts.allow在簡單配置可以不修改,
如遇此兩個檔案唯讀,可以chmod提權
最後重啟動SSH啟動
# /etc/rc.d/init.d/sshd restart
centos 安裝配置ssh