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: Chinese Post (中文帖子)

Posted on September 7, 2022November 22, 2024

[排错] Linux 解决执行 service crond status 命令时,报错 “crond dead but pid file exists”

报错代码

crond dead but pid file exists

解决方法

步骤一:找到 crond.pid 文件

# find / -name cron*
/spool/anacron/cron.daily
/spool/anacron/cron.weekly
/spool/anacron/cron.monthly
/spool/cron
/lock/subsys/crond
/run/cron.reboot
/run/crond.pid

步骤二:删除 crond.pid 文件

# rm -rf crond.pid
Posted on September 7, 2022April 11, 2023

[排错] 解决 Linux 执行 Shell 脚本时报错 “[: ……: unary operator expected”

报错代码

[: ......: unary operator expected

解决方法

# vim <Shell Script>

将以下内容修改为:

......
if [[ ...... ]]; 
......

修改为:

......
if [[ ...... ]]; 
......
Posted on August 29, 2022June 26, 2025

[步骤] Linux SSH 加密方式 (cipher) 、信息验证代码 (message authentication code) 和算法 (algorithm) 的设置 (Ciphers、MACs 和 KexAlgorithms 参数的设置) (不使用来自 crypto policies 的系统全局设置) (RHEL 8 版)

注意:

RHEL 8 的 SSH 加密算法默认会使用来自 crypto policies 系统的全局 SSH 加密算法,而此方法将让 SSH 使用单独设置的 SSH 加密算法。

正文:

步骤一:启用 SSH 配置文件里加密方式 (cipher) 、信息验证代码 (message authentication code)和算法 (algorithm) 的设置

1.1 备份 /etc/sysconfig/sshd 配置文件

# cp /etc/sysconfig/sshd /etc/sysconfig/sshd_backup

1.2 修改 /etc/sysconfig/sshd 配置文件

# vim /etc/sysconfig/sshd

将以下内容:

# CRYPTO_POLICY=

修改为:

......
CRYPTO_POLICY=
......

步骤二:在 /etc/ssh/sshd_config 配置文件中设置要使用的 Ciphers、MACs 和 KexAlgorithm 参数

2.1 备份 /etc/ssh/sshd_config 配置文件

# cp /etc/ssh/sshd_config /etc/ssh/sshd_config_backup

2.2 在 /etc/ssh/sshd_config 配置文件中添加要使用的 Ciphers、MACs 和 KexAlgorithms 参数

# vim /etc/ssh/sshd_config

添加以下内容:

......
Ciphers aes256-gcm@openssh.com,aes128-gcm@openssh.com,aes256-ctr,aes192-ctr,aes128-ctr
MACs hmac-sha2-512,hmac-sha2-256
KexAlgorithms ecdh-sha2-nistp521,ecdh-sha2-nistp384,ecdh-sha2-nistp256,diffie-hellman-group-exchange-sha256

(
补充:这里以使用:
1) aes256-gcm@openssh.com、aes128-gcm@openssh.com、aes256-ctr、aes192-ctr 和 aes128-ctr SSH 加密方式 (cipher)
2) hmac-sha2-512 和 hmac-sha2-256 SSH 信息验证代码 (message authentication code)
3) ecdh-sha2-nistp521、ecdh-sha2-nistp384、ecdh-sha2-nistp256 和 diffie-hellman-group-exchange-sha256 SSH 算法 (algorithm)
为例
)

2.3 让在 /etc/ssh/sshd_config 配置文件中添加要使用的 Ciphers、MACs 和 KexAlgorithms 参数生效

# systemctl restart sshd

步骤三:测试 SSH 加密方式 (cipher)和算法 (algorithm)

3.1 测试 SSH Ciphers 参数

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

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

3.1.2 测试多个 SSH 加密方式 (ciphers)
# 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) 为例)

3.2 测试 SSH MACs 参数

3.2.1 测试某个 SSH ciphers 加密算法
# ssh -vv -oMACs=hmac-md5 -oPort=22 192.168.0.1

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

3.2.2 测试多个 SSH ciphers 加密算法
# 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) 为例)

3.3 显示所有在使用的 SSH 加密方式 (cipher)和算法 (algorithm)

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

(补充:这里以测试 IP 地址是 192.168.0.1,端口号是 22 为例)

参考文献:

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

Posted on August 15, 2022November 21, 2023

[内容] nftables 防火墙策略文件的常用规则

注意:

在给 nftables 防火墙的策略文件添加规则前,要先使用 nftables 防火墙的策略文件:

nftables 防火墙的使用
(永久版)

正文:

案例一:允许某个 IP 地址访问某个端口

ip saddr 192.168.0.1 tcp dport ssh accept

或者:

ip saddr 192.168.0.1 tcp dport 22 accept

(补充:这里以允许 IP 地址 192.168.0.1 访问 22 端口为例)

案例二:允许某个 IP 地址访问多个端口

ip saddr 192.168.0.1 tcp dport {22,80,443,3306,100,101,102,103} accept

或者:

ip saddr 192.168.0.1 tcp dport {22,80,443,3306,100-103} accept

(补充:这里以允许 IP 地址 192.168.0.1 访问 22 端口、80 端口、443 端口、3066 端口和 100 端口到 103 端口为例)

案例三:允许多个 IP 地址访问多个端口

ip saddr {192.168.0.1,192.168.0.2,192.168.0.3} tcp dport {22,80,443,3306} accept comment "accept local port"

或者:

ip saddr {192.168.0.1-192.168.0.3} tcp dport {22,80,443,3306} accept comment "accept local port"

(补充:这里以允许 IP 地址 192.168.0.1、192.168.0.2 和 192.168.0.3 访问 22 端口、80 端口、443 端口和 3066 端口并添加注释 “accept local port” 为例)

案例四:拒绝所有 IP 地址访问多个端口

tcp dport {22,80,443,3306} drop comment "drop remote port"

(补充:这里以拒绝所有 IP 地址的 22 端口、80 端口、443 端口和 3306 端口并添加注释 “drop remote port” 为例)

案例五:拒绝所有 IP 地址访问所有端口

tcp dport {0-65535} drop
udp dport {0-65535} drop

案例六:允许某个 IP 地址可以通过 ICMP 协议 ping 通

ip saddr 192.168.0.1 ip protocol icmp icmp type echo-request accept

(补充:这里以允许 192.168.0.1 可以通过 ICMP 协议 ping 通为例)

案例七:允许由本发出请求后,回应请求的数据可以进入

ct state { established, related } accept
Posted on August 15, 2022November 22, 2024

[排错] openSUSE & SLES 解决执行 systemctl enable 命令或者 systemd-sysv-install enable 命令时报错 “…..: No such file or directory”

报错代码

......: No such file or directory

解决方法

# zypper in insserv-compat

Posts pagination

Previous page Page 1 … Page 33 Page 34 Page 35 … Page 172 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