安裝SSH
yum install ssh 安全
啓動SSH
service sshd start 服務器
設置開機運行
chkconfig sshd on ssh
相關配置文件修改
[root@sample ~]# vi /etc/ssh/sshd_config ← 用vi打開SSH的配置文件
tcp
#Protocol 2,1 ← 找到此行將行頭「#」刪除,再將行末的「,1」刪除,只容許SSH2方式的鏈接
↓
Protocol 2 ← 修改後變爲此狀態,僅使用SSH2 ide
#ServerKeyBits 768 ← 找到這一行,將行首的「#」去掉,並將768改成1024
↓
ServerKeyBits 1024 ← 修改後變爲此狀態,將ServerKey強度改成1024比特 .net
#PermitRootLogin yes ← 找到這一行,將行首的「#」去掉,並將yes改成no
↓
PermitRootLogin no ← 修改後變爲此狀態,不容許用root進行登陸 rest
#PasswordAuthentication yes ← 找到這一行,將yes改成no
↓
PasswordAuthentication no ← 修改後變爲此狀態,不容許密碼方式的登陸 server
#PermitEmptyPasswords no ← 找到此行將行頭的「#」刪除,不容許空密碼登陸
↓
PermitEmptyPasswords no ← 修改後變爲此狀態,禁止空密碼進行登陸 ci
由於咱們只想讓SSH服務爲管理系統提供方便,因此在不經過外網遠程管理系統的狀況下,只容許內網客戶端經過SSH登陸到服務器,以最大限度減小不安全因素。設置方法以下:
[root@sample ~]# vi /etc/hosts.deny ← 修改屏蔽規則,在文尾添加相應行 rem
#
# 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