1、 建立私有CA并進行證書申請。
(1)建立CA所需要的檔案
touch /etc/pki/CA/index.txt
echo 01 > /etc/pki/CA/serial

(2)生成CA私鑰
umask 066; openssl genrsa -out private/cakey.pem 2048
(3)給CA頒發自簽名證書
openssl req -new -x509 -key /etc/pki/CA/private/cakey.pem -days 3650 -out /etc/pki/CA/cacert.pem
檢視證書:
openssl x509 -in /etc/pki/CA/cacert.pem -noout –text
(4)使用者生成私鑰和證書申請
mkdir /data/app1
umask 066; openssl genrsa -out /data/app1/app1.key 2048
使用者證書申請:
openssl req -new -key /data/app1/app1.key -out /data/app1/app1.csr
5)頒發證書
openssl ca -in /data/app1/app1.csr -out /etc/pki/CA/certs/app1.crt -days 1000
(6)将證書相關檔案發送到使用者端使用
cp /etc/pki/CA/certs/app1.crt /data/app1/
2、 總結ssh常用參數、用法
ssh指令是ssh用戶端,允許實作對遠端系統經驗證地加密安全通路。ssh用戶端配置檔案是:/etc/ssh/ssh_config
ssh指令配合的常見選項:
-p port:遠端伺服器監聽的端口
ssh 192.168.1.8 -p 2222
-b 指定連接配接的源IP
ssh 192.168.1.8 -p 2222 -b 192.168.1.88
-v 調試模式
ssh 192.168.1.8 -p 2222 -v
-C 壓縮方式
-X 支援x11轉發
支援将遠端linux主機上的圖形工具在目前裝置使用
-t 強制僞tty配置設定,如:ssh -t remoteserver1 ssh -t remoteserver2 ssh
remoteserver3
-o option 如:-o StrictHostKeyChecking=no
-i 指定私鑰檔案路徑,實作基于key驗證,預設使用檔案: ~/.ssh/id_dsa,
~/.ssh/id_ecdsa, /.ssh/id_ed25519,/.ssh/id_rsa等
3、總結sshd服務常用參數。
伺服器端的配置檔案: /etc/ssh/sshd_config
常用參數:
Port #端口号
ListenAddress ipLoginGraceTime 2m #寬限期
PermitRootLogin yes #預設ubuntu不允許root遠端ssh登入
StrictModes yes #檢查.ssh/檔案的所有者,權限等
MaxAuthTries 6
MaxSessions 10 #同一個連接配接最大會話
PubkeyAuthentication yes #基于key驗證
PermitEmptyPasswords no #空密碼連接配接
PasswordAuthentication yes #基于使用者名和密碼連接配接
GatewayPorts no
ClientAliveInterval 10 #機關:秒
ClientAliveCountMax 3 #預設3
UseDNS yes #提高速度可改為no
GSSAPIAuthentication yes #提高速度可改為no
MaxStartups #未認證連接配接最大值,預設值10
Banner /path/file
以下可以限制可登入使用者的辦法:
AllowUsers user1 user2 user3
DenyUsers
AllowGroups
ssh服務的最佳實踐
建議使用非預設端口
禁止使用protocol version 1
限制可登入使用者
設定空閑會話逾時時長
利用防火牆設定ssh通路政策僅監聽特定的IP位址
基于密碼認證時,使用強密碼政策,比如:tr -dc A-Za-z0-9_ < /dev/urandom | head -c 12|
xargs
使用基于密鑰的認證
禁止使用空密碼
禁止root使用者直接登入
限制ssh的通路頻度和并發線上數
經常分析日志
4、搭建dhcp服務,實作ip位址申請分發
1).伺服器端安裝DHCP服務
yum install dhcp
2).将DHCP配置模闆 dhcpd.conf.sample 複制到 /etc/dhcp/ 下,替換dhcpd.conf
cp /usr/share/doc/dhcp-4.2.5/dhcpd.conf.example /etc/dhcp/dhcpd.conf
3).設定DHCP服務開機啟動
chkconfig dhcpd on
4).配置檔案更改
subnet 192.168.0.0 netmask 255.255.255.0 {
range 192.168.0.100 192.168.0.200;
option domain-name-servers 192.168.0.1;
option domain-name “internal.example.org”;
option routers 192.168.0.1;
option broadcast-address 192.168.8.255;
default-lease-time 600;
max-lease-time 7200;
host xuegod63 { #這一段内容,要寫在subnet字段中,和subnet配合使用。
hardware ethernet 00:0C:29:12:ec:1e;
fixed-address 192.168.0.251;
}
5).DHCP服務啟動
service dhcpd start
6).用戶端将網卡 eth0 和 eth1 配置為DHCP方式擷取IP。
7).重新開機網絡服務
service network restart
8).檢視是否通過DHCP自動擷取IP,同時eth0 的IP是否綁定為 192.168.8.2