Skip to content
Eternal Center

Eternal Center

  • Single-Node (单节点)
    • System (系统)
    • Service (服务)
    • Database (数据库)
    • Container (容器)
    • Virtualization (虚拟化)
  • Multi-Node (多节点)
    • Cluster (集群)
    • Big Data (大数据)
    • Cloud Computing (云计算)
    • Batch Processing (批量处理)
  • Approach (方式方法)
    • Languages (语言)
    • Ideas (思路)
    • Programing (编程)
    • Project (项目)
  • Eternity (永恒)
    • News (消息)
    • Creations (创作)
    • Classics (经典)
    • Legends (传说)
    • Chronicle (编年史)
    • FNIOS (宇宙公民开源学院)

Month: February 2023

Posted on February 17, 2023January 5, 2026

[步骤] Linux SSH 加密方式 (cipher) 、信息验证代码 (message authentication code) 和算法 (algorithm) 的设置 (Ciphers 参数、MACs 参数和 KexAlgorithms 参数的设置) (RHEL 8 版)

正文:

步骤一:确定 CRYPTO_POLICY 参数没有生效

# vim /etc/sysconfig/sshd

确保部分内容如下:

......
# CRYPTO_POLICY=
......

步骤二:在 /etc/crypto-policies/back-ends/opensshserver.config 配置文件中确认要使用的 Ciphers、MACs 和 KexAlgorithm 参数

2.1 备份 /etc/crypto-policies/back-ends/opensshserver.config 配置文件

# cp /etc/crypto-policies/back-ends/opensshserver.config /etc/crypto-policies/back-ends/opensshserver.config.backup

2.2 修改 /etc/crypto-policies/back-ends/opensshserver.config 配置文件

# vim /etc/crypto-policies/back-ends/opensshserver.config

添加需要使用的 SSH 算法 (algorithms) 和加密方式 (ciphers):

(内容略)

(注意:如果需要使用的 SSH 加密方式 (cipher) 、信息验证代码 (message authentication code) 和算法 (algorithm) ,已包含在其中了则可以不用添加)

2.3 显示目前正在被使用的 SSH 算法 (algorithms) 和加密方式 (ciphers)

# printf "%s\n" $(source /etc/crypto-policies/back-ends/opensshserver.config; echo $CRYPTO_POLICY) | cut -c3-
[email protected],[email protected],aes256-ctr,aes256-cbc,[email protected],aes128-ctr,aes128-cbc
[email protected],[email protected],[email protected],[email protected],hmac-sha2-256,hmac-sha1,[email protected],hmac-sha2-512
GSSAPIKexAlgorithms=gss-curve25519-sha256-,gss-nistp256-sha256-,gss-group14-sha256-,gss-group16-sha512-,gss-gex-sha1-,gss-group14-sha1-
KexAlgorithms=curve25519-sha256,[email protected],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,diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1
HostKeyAlgorithms=ecdsa-sha2-nistp256,[email protected],ecdsa-sha2-nistp384,[email protected],ecdsa-sha2-nistp521,[email protected],ssh-ed25519,[email protected],rsa-sha2-256,[email protected],rsa-sha2-512,[email protected],ssh-rsa,[email protected]
PubkeyAcceptedKeyTypes=ecdsa-sha2-nistp256,[email protected],ecdsa-sha2-nistp384,[email protected],ecdsa-sha2-nistp521,[email protected],ssh-ed25519,[email protected],rsa-sha2-256,[email protected],rsa-sha2-512,[email protected],ssh-rsa,[email protected]
CASignatureAlgorithms=ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,ssh-ed25519,rsa-sha2-256,rsa-sha2-512,ssh-rsa

(补充:这里以显示 RHEL 8 默认使用的 SSH 加密方式 (cipher)、信息验证代码 (message authentication code) 和算法 (algorithm) 为例)

步骤三:让在 /etc/crypto-policies/back-ends/opensshserver.config 配置文件中添加要使用的 SSH 加密方式 (cipher) 、信息验证代码 (message authentication code) 和算法 (algorithm) 生效

# systemctl restart sshd

步骤四:测试 SSH 加密方式 (cipher) 、信息验证代码 (message authentication code) 和算法 (algorithm)

4.1 测试 SSH 加密方式 (cipher)

4.1.1 测试某个 SSH 加密方式 (cipher)
# ssh -vv -oCiphers=3des-cbc -oPort=22 192.168.0.1

(补充:这里以测试 IP 地址是 192.168.0.1,端口号是 22,有没有启用 3des-cbc SSH 加密方式 (cipher) 为例)

4.1.2 测试多个 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) 为例)

4.2 测试 SSH 信息验证代码 (message authentication code)

4.2.1 测试某个 SSH 信息验证代码 (message authentication code)
# ssh -vv -oMACs=hmac-md5 -oPort=22 192.168.0.1

(补充:这里以测试 IP 地址是 192.168.0.1,端口号是 22,有没有启用 hmac-md5 SSH 信息验证代码 (message authentication code) 为例)

4.2.2 测试多个 SSH 信息验证代码 (message authentication code)
# ssh -vv -oMACs=hmac-md5,hmac-md5-96,hmac-sha1,hmac-sha1-96,[email protected],[email protected] -oPort=22 192.168.0.1

(补充:这里以测试 IP 地址是 192.168.0.1,端口号是 22,有没有启用 hmac-md5、hmac-md5-96、hmac-sha1、hmac-sha1-96、[email protected] 和 [email protected] SSH 信息验证代码 (message authentication code) 为例)

4.3 显示所有在使用的 SSH 加密方式 (cipher) 、信息验证代码 (message authentication code) 和算法 (algorithm)

4.3.1 使用 sshd 命令显示所有在使用的加密方式 (cipher) 、信息验证代码 (message authentication code)
# sshd -T | egrep -i "ciphers|macs|kexalgorithms"
4.3.2 使用 nmap 命令显示所有在使用的 SSH 加密方式 (cipher) 、信息验证代码 (message authentication code) 和算法 (algorithm)
# nmap --script ssh2-enum-algos -sV -p 22 127.0.0.1

(补充:这里以测试本地的 22 端口为例)

4.3.3 使用 nmap 命令显示所有在使用的 SSH 加密方式 (cipher) 、信息验证代码 (message authentication code) 和算法 (algorithm)
# ssh -vvv 127.0.0.1

(补充:这里以测试本地的 22 端口为例)

参考文献:

https://access.redhat.com/solutions/4410591
https://access.redhat.com/solutions/4278651

Posted on February 17, 2023November 22, 2024

[内容] Linux 功能的限制

正文:通过 /etc/security/access.conf 文件实现 Linux 功能使用的限制

# vim /etc/security/access.conf

添加以下内容:

......
+ : root : LOCAL
+ : zhumingyu : ALL
+ : @cron : ALL
- : ALL : ALL

(
补充:这里以
1) 允许 root 用户使用本地的所有功能
2) 允许 zhumingyu 用户使用所有功能
3) 允许 cron 功能被所有用户使用
4) 其它所有的功能或用户都被禁止
为例
)

补充:使 /etc/security/access.conf 文件的配置失效

# vim /etc/pam.d/crond

将部分内容修改如下:

......
#account required pam_access.so
......

Aspiration (愿景):

Everyone can achieve self-achievement and self-happiness fairly.

每个人都能公平地实现自我成就和自我幸福。

Logo (徽标):

Additional Information (其他信息):

About     Manual     Clone     Contact
Disclaimer     Friendly Links     Donation

关于     手册     克隆     联系
免责声明     友情链接     捐赠

Search Inside Website (站内搜索):

Search Outside Website (站外搜索):

Google         Wikipedia         Bing
Proudly powered by LNMP Proudly powered by WordPress