步骤一:设置最大 PID 数
# vi /etc/sysctl.conf
添加以下内容:
......
kernel.pid_max=102400
(补充:这里以把 PID 数设置成 102400 为例)
步骤二:让修改的 /etc/sysctl.conf 文件生效
# sysctl -p /etc/sysctl.conf
# vi /etc/sysctl.conf
添加以下内容:
......
kernel.pid_max=102400
(补充:这里以把 PID 数设置成 102400 为例)
# sysctl -p /etc/sysctl.conf
# vi /etc/ld.so.conf
或者:
# vi /etc/ld.so.conf.d/*.conf
添加以下内容:
......
/root/lib
(补充:这里以添加位于目录 /root/lib 的库为例)
(注意:这里的 /etc/ld.so.conf.d/*.conf 是指 /etc/ld.so.conf.d/ 目录下任意以 .conf 结尾的文件,例如 /etc/ld.so.conf.d/one.conf)
# cp /boot/initramfs-4.18.0-553.89.1.el8_10.x86_64.img /boot/initramfs-4.18.0-553.89.1.el8_10.x86_64.img.backup
(
补充:
1) 这里以将:/boot/initramfs-4.18.0-553.89.1.el8_10.x86_64.img 备份为:/boot/initramfs-4.18.0-553.89.1.el8_10.x86_64.img.backup 为例
2) initramfs 是压缩的 cpis 文件,是临时的根文件系统包含一些脚本、程序和配置文件,在 Linux 启动过程中被加载在内存里,负责 Linux 操作系统在挂载根目录前加载内核模块、检查硬件、加载驱动以及挂载真正的根文件系统等)
# dracut -f /boot/initramfs-(uname -r).img $(uname -r)
(补充:这里以将正在运行的内核版本生成一个新的 initramfs 为例)
(注意:此时原来启动系统时使用的那个 initramfs 文件会被覆盖)
# reboot
# ldconfig -p -M -X | grep out
(
补充:
1) 这里的 -N 和 -X 必须一起使用,作用是不更新相关链接和不重建相关缓存
2) 这里的 -p 作用是打印现在在缓存中的相关目录和相关候选库
3) 这条命令会显示目前在缓存中的第三方库
)
# for l in $(ldconfig -p -N -X | awk '{ print $1 }') ; do matches=$(ldconfig -p -N -X | awk "\$1 == \"$l\" { print }"); if [ $(echo "$matches" | wc -l) -ge 2 ]; then echo "$matches"; echo; fi; done |wc -l
(补充:如果加载的库中没有重复的则这里不会有任何输出结果)
# vim /etc/ssh/sshd_config
确保部分内容如下:
......
Include /etc/ssh/sshd_config.d/*.conf
......
Include /usr/etc/ssh/sshd_config.d/*.conf
......
# vim /etc/ssh/sshd_config.d/*.conf
或者:
# vim /usr/etc/ssh/sshd_config.d/*.conf
确保部分内容如下:
......
Include /etc/crypto-policies/back-ends/opensshserver.config
......
# cp /etc/crypto-policies/back-ends/opensshserver.config /etc/crypto-policies/back-ends/opensshserver.config.backup
# vim /etc/crypto-policies/back-ends/opensshserver.config
添加需要使用的 SSH 算法 (algorithms) 和加密方式 (ciphers):
(内容略)
(注意:如果需要使用的 SSH 加密方式 (cipher) 、信息验证代码 (message authentication code) 和算法 (algorithm) ,已包含在其中了则可以不用添加)
# cat /etc/crypto-policies/back-ends/opensshserver.config
Ciphers aes256-gcm@openssh.com,aes256-ctr,aes128-gcm@openssh.com,aes128-ctr
MACs hmac-sha2-256-etm@openssh.com,hmac-sha1-etm@openssh.com,hmac-sha2-512-etm@openssh.com,hmac-sha2-256,hmac-sha1,hmac-sha2-512
GSSAPIKexAlgorithms gss-nistp256-sha256-,gss-group14-sha256-,gss-group16-sha512-
KexAlgorithms ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group14-sha256,diffie-hellman-group16-sha512,diffie-hellman-group18-sha512
HostKeyAlgorithms ecdsa-sha2-nistp256,ecdsa-sha2-nistp256-cert-v01@openssh.com,sk-ecdsa-sha2-nistp256@openssh.com,sk-ecdsa-sha2-nistp256-cert-v01@openssh.com,ecdsa-sha2-nistp384,ecdsa-sha2-nistp384-cert-v01@openssh.com,ecdsa-sha2-nistp521,ecdsa-sha2-nistp521-cert-v01@openssh.com,ssh-ed25519,ssh-ed25519-cert-v01@openssh.com,sk-ssh-ed25519@openssh.com,sk-ssh-ed25519-cert-v01@openssh.com,rsa-sha2-256,rsa-sha2-256-cert-v01@openssh.com,rsa-sha2-512,rsa-sha2-512-cert-v01@openssh.com
PubkeyAcceptedAlgorithms ecdsa-sha2-nistp256,ecdsa-sha2-nistp256-cert-v01@openssh.com,sk-ecdsa-sha2-nistp256@openssh.com,sk-ecdsa-sha2-nistp256-cert-v01@openssh.com,ecdsa-sha2-nistp384,ecdsa-sha2-nistp384-cert-v01@openssh.com,ecdsa-sha2-nistp521,ecdsa-sha2-nistp521-cert-v01@openssh.com,ssh-ed25519,ssh-ed25519-cert-v01@openssh.com,sk-ssh-ed25519@openssh.com,sk-ssh-ed25519-cert-v01@openssh.com,rsa-sha2-256,rsa-sha2-256-cert-v01@openssh.com,rsa-sha2-512,rsa-sha2-512-cert-v01@openssh.com
HostbasedAcceptedAlgorithms ecdsa-sha2-nistp256,ecdsa-sha2-nistp256-cert-v01@openssh.com,sk-ecdsa-sha2-nistp256@openssh.com,sk-ecdsa-sha2-nistp256-cert-v01@openssh.com,ecdsa-sha2-nistp384,ecdsa-sha2-nistp384-cert-v01@openssh.com,ecdsa-sha2-nistp521,ecdsa-sha2-nistp521-cert-v01@openssh.com,ssh-ed25519,ssh-ed25519-cert-v01@openssh.com,sk-ssh-ed25519@openssh.com,sk-ssh-ed25519-cert-v01@openssh.com,rsa-sha2-256,rsa-sha2-256-cert-v01@openssh.com,rsa-sha2-512,rsa-sha2-512-cert-v01@openssh.com
CASignatureAlgorithms ecdsa-sha2-nistp256,sk-ecdsa-sha2-nistp256@openssh.com,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,ssh-ed25519,sk-ssh-ed25519@openssh.com,rsa-sha2-256,rsa-sha2-512
RequiredRSASize 2048
(补充:这里以显示 openSUSE & SLES 默认使用的 SSH 加密方式 (cipher)、信息验证代码 (message authentication code) 和算法 (algorithm) 为例)
# systemctl restart sshd
# ssh -vv -oCiphers=3des-cbc -oPort=22 192.168.0.1
(补充:这里以测试 IP 地址是 192.168.0.1,端口号是 22,有没有启用 3des-cbc SSH 加密方式 (cipher) 为例)
# ssh -vv -oCiphers=3des-cbc,aes128-cbc,aes192-cbc,aes256-cbc -oPort=22 192.168.0.1
(补充:这里以测试 IP 地址是 192.168.0.1,端口号是 22,有没有启用 3des-cbc、aes128-cbc、aes192-cbc 和 aes256-cbc SSH 加密方式 (cipher) 为例)
# ssh -vv -oMACs=hmac-md5 -oPort=22 192.168.0.1
(补充:这里以测试 IP 地址是 192.168.0.1,端口号是 22,有没有启用 hmac-md5 SSH 信息验证代码 (message authentication code) 为例)
# ssh -vv -oMACs=hmac-md5,hmac-md5-96,hmac-sha1,hmac-sha1-96,hmac-md5-etm@openssh.com,hmac-md5-96-etm@openssh.com -oPort=22 192.168.0.1
(补充:这里以测试 IP 地址是 192.168.0.1,端口号是 22,有没有启用 hmac-md5、hmac-md5-96、hmac-sha1、hmac-sha1-96、hmac-md5-etm@openssh.com 和 hmac-md5-96-etm@openssh.com SSH 信息验证代码 (message authentication code) 为例)
# sshd -T | egrep -i "ciphers|macs|kexalgorithms"
# nmap --script ssh2-enum-algos -sV -p 22 127.0.0.1
(补充:这里以测试本地的 22 端口为例)
# ssh -vvv 127.0.0.1
(补充:这里以测试本地的 22 端口为例)
配置文件格式:
-w <file> -p wa -k <search_key>
命令格式:
# auditctl -w <file> -p wa -k <search_key>
(
补充:
1) 这里的 <file> 是要监控的文件
2) 这里的 <search_key> 是个标识,用于简化在 audit 日志里搜索此命令
)
配置文件的案例:
-w /etc/group -p wa -k group_file
命令案例:
# auditctl -w /etc/group -p wa -k group_file
(
补充:这里以
1) 监控 /etc/group 文件
2) 标识是 group_file 为例
)
# augenrules
# service auditd restart
# auditctl -l
# ausearch -k group_file
(补充:这里以查看标识为 group_file 的 audit 日志为例)
https://access.redhat.com/solutions/3401281
记录需要使用的网络端口的网卡机器码 (MAC) 地址
(步骤略)
(
注意:
1) 只有物理机才需要完成这步
2) 当物理机 1 个网络模块上有 2 个网络端口时,要特别注意 2 个网络端口各自的网卡机器码 (MAC) 地址,例如:戴尔服务器网络端口的网卡机器码 (MAC) 地址在页面的最下方
)
# ip a s
或者:
# ip address show
(补充:当出现 ”UP“ 字样时代表网卡已经启动)
(注意:nmcli device show 命令不能确认此时网卡是否联通)
# ethtool eth0
(注意:nmcli device show 命令不能确认此时网卡是否联通)
# ifconfig eth0 192.168.0.2/24
或者:
# ip a add 192.168.0.2/24 dev eth0
(补充:这里以给 eth0 网卡添加临时 IP 地址 192.168.0.2/24 为例)
(注意:只有当确认网卡是联通的时候才进行此操作)
# route add default gw 192.168.0.1
或者:
# ip route add default via 192.168.0.1
(注意:只有当确认网卡是联通的时候才进行此操作)
# ip a s
# route -n