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 (宇宙公民开源学院)

Category: System Login Security (系统登录安全)

Posted on January 5, 2026January 6, 2026

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

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

1.1 确定 /etc/ssh/sshd_config 文件

# vim /etc/ssh/sshd_config

确保部分内容如下:

......
Include /etc/ssh/sshd_config.d/*.conf
......
Include /usr/etc/ssh/sshd_config.d/*.conf
......

1.2 确定 /usr/etc/ssh/sshd_config.d/*.conf 文件或者 /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
......

步骤二:在 /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)

# 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) 为例)

步骤三:让在 /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,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) 为例)

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 端口为例)

Posted on September 9, 2025

[内容] Linux 登录终端的分类

内容一:Linux 登录终端的分类

Linux 登录终端分为 3 类:
1) pts (伪终端)
2) tty* (图形终端)
3) ttyS* (串行口终端)

内容二:不同的登录终端会被使用的情况

2.1 pts (伪终端) 会被使用到的情况

ssh 远程登录

2.2 tty* (图形终端) 会被使用到的情况

1) VMware 的 console 口
2) DELL 物理机的 IDRAC 口

2.3 ttyS* (串行口终端) 会被使用到的情况

内容三:登录终端类型的管理

3.1 查看当前使用的登录终端类型

# tty

3.2 设置当前系统允许使用的 登录终端类型

# cat /etc/securetty
Posted on March 27, 2025March 27, 2025

[命令] Linux 命令 loginctl 的使用 (查看和管理所有 SSH 登录会话\进程)

内容一:查看所有 SSH 登录会话\进程

# loginctl -a
SESSION   UID USER         SEAT TTY  
     27  1001 mingyuzhu      pts/0

(
补充:从输出结果可以看出
1) 会话\进程的 SESSION 号码为 27
2) 创建会话\进程的用户 UID 是 1001
3) 创建会话\进程的用户是 mingyuzhu
4) 创建会话\进程的 SEAT TTY 是 pts/0
)

内容二:关闭某个 SSH 登录会话\进程

# loginctl terminate-session 27

(补充:这里以关闭 SESSION 号码是 27 的会话\进程为例)

内容三:批量关闭某个用户通过 SSH 登录的所有会话\进程

3.1 批量关闭某个用户通过 SSH 登录的所有会话\进程 (显示输出结果)

# loginctl -a | grep mingyuzhu| awk '{print "loginctl terminate-session  "$1;system("loginctl terminate-session "$1"")}'

3.2 批量关闭某个用户通过 SSH 登录的所有会话\进程 (不显示输出结果)

# loginctl -a | grep mingyuzhu| awk '{print "loginctl terminate-session  "$1;system("loginctl terminate-session "$1"")}' > /dev/null

或者:

# loginctl -a | grep mingyuzhu| `awk '{print "loginctl terminate-session  "$1;system("loginctl terminate-session "$1"")}'`
Posted on March 26, 2025December 31, 2025

[排错] Linux 解决使用 authselect apply-changes 命令时报错 “[error] [……] has unexpected content!”

报错命令

# authselect apply-changes

报错代码

[error] [/....../system-auth] has unexpected content!
[error] [/....../password-auth] has unexpected content!
[error] [/....../nsswitch.conf] has unexpected content!
[error] Unexpected changes to the configuration were detected.
[error] Refusing to activate profile unless those changes are removed or overwrite is requested.
Some unexpected changes to the configuration were detected. Use 'select' command instead.

解决方法

创建新的 authselect 文件

步骤一:移走原来的 authselect 文件

# mv /etc/authselect/custom/password-policy /etc/authselect/custom/password-policy-backup

步骤二:创建新的 authselect 的文件

# authselect create-profile password-policy -b sssd --symlink-meta --symlink-pam

步骤三:使用新创建的 authselect 文件

# authselect select custom/password-policy with-sudo with-faillock without-nullok with-mkhomedir --force

步骤四:启用 oddjob 服务

# dnf install oddjob ; systemctl enable --now oddjobd.service

步骤五:启用新的 authselect 文件

# authselect apply-changes
Posted on March 20, 2025March 20, 2025

[步骤] Linux audit 日志的查看 (判断哪个文件是被哪个用户修改过)

步骤一:查看在 audit 日志中文件被修改的日志编号

# cat /var/log/audit/audit.log | grep test.txt
......
type=PATH msg=audit(1532475291.426:18858423)......
......

(
补充:
1) 这里以查看在 audit 日志中文件 test.txt 被修改的记录为例
2) 从这里的输出结果可以看到此次的修改记录中日志的编号是 18858423
)

步骤二:在 audit 日志中查看和此日志编号相同的的日志里记录的 PPID

# cat /var/log/audit/audit.log | grep ppid | grep 18858423
......
...... ppid=6027281 ......
......

(
补充:
1) 这里以查看在 audit 日志中和日志编号 18858423 相同的的日志里记录的 PPID 为例
2) 这里的日志编号 18858423 是在步骤一中查到的
3) 从这里的输出结果可以看到和此日志编号相同的日志里记录的 PPID 是 6027281
)

步骤三:在系统日志中查看哪个用户登录系统时生成的是此 PPID

# cat /var/log/messages | grep terminal=ssh  | grep 6027281

(
补充:
1) 这里以查看在系统日志中哪个用户登录系统时生成的是 PPID 6027281 为例
2) 这里的 PPID 6027281 是在步骤二中查到的
)

Posts pagination

Page 1 Page 2 … Page 24 Next page

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

Eternal URL (永恒网址):

https://eternity.eternalcenter.com Will be last access method / 将是最后的访问方式

Proudly powered by LNMP Proudly powered by WordPress