标签 Linux 下的文章

1.OpenSSL版本升级

https://computingforgeeks.com/how-to-install-openssl-1-1-on-centos-rhel-7/

1.1 安装依赖

$ sudo yum -y groupinstall "Development Tools"

1.2 下载openssl且编译

$ wget https://www.openssl.org/source/openssl-1.1.1w.tar.gz
$ tar xvf openssl-1.1.1w.tar.gz
$ cd openssl-1.1.1w
$ ./config --prefix=/usr/local/openssl --openssldir=/usr/local/openssl
Operating system: x86_64-whatever-linux2
Configuring OpenSSL version 1.1.1w (0x1010117fL) for linux-x86_64
Using os-specific seed configuration
Creating configdata.pm
Creating Makefile

**********************************************************************
***                                                                ***
***   OpenSSL has been successfully configured                     ***
***                                                                ***
***   If you encounter a problem while building, please open an    ***
***   issue on GitHub <https://github.com/openssl/openssl/issues>  ***
***   and include the output from the following command:           ***
***                                                                ***
***       perl configdata.pm --dump                                ***
***                                                                ***
***   (If you are new to OpenSSL, you might want to consult the    ***
***   'Troubleshooting' section in the INSTALL file first)         ***
***                                                                ***
**********************************************************************

- 阅读剩余部分 -

前提:在Synology NAS共享文件中NFS权限标签页新增NFS规则,输入需要访问NFS共享的系统的IP。其余保留默认选项并单击“确定”。

系统IP必须同上面设置的IP相同

1.Install NFS common tools

sudo apt-get update
sudo apt-get install nfs-common -y

2.创建挂载目录

sudo mkdir -p /nfs/temp

3.临时挂载

sudo mount 192.168.1.10:/volume1/Temp /nfs/temp
# 卸载
sudo umount /nfs/temp

4.持久挂载

重启后自动挂载
编辑文件/etc/fstab
192.168.1.10:/volume1/Temp         /nfs/temp nfs     defaults        0       0

5.测试权限

sudo chown -R user:group /nfs/temp
sudo chmod -R 755 /nfs/temp
# check permissions with stat
stat /nfs/temp

1.生成 RSA 证书

acme.sh --issue -d www.example.com -w /var/www/ssl/

2.生成 ECC 证书

acme.sh --issue -d www.example.com -w /var/www/ssl/ --keylength ec-256
ECC证书:ECC证书是基于ECC算法的SSL证书,ECC证书中文名称为椭圆加密算法,新一代算法趋势主流,一般采用 256 位加密长度,加密速度快,效率更高,对服务器资源消耗低,而且最重要的是更安全,抗攻击型更强。
RSA证书:RSA证书是基于RSA算法的SSL证书,RSA算法是国际标准算法,应用较早,最为普及,比ECC算法的适用范围更广,兼容性更好,一般采用 2048 位的加密长度,但是对服务端性能消耗高。

3.安装 ECC 证书

acme.sh --installcert -d www.example.com   \
        --key-file   /ssl/www.example.com.key \
        --fullchain-file /ssl/www.example.com.crt \
        --reloadcmd  "systemctl reload nginx" --ecc

4.更新SSL证书

acme.sh --renew -d www.example.com --ecc --force

5.取消SSL证书的自动续期

acme.sh --remove -d www.example.com --ecc

一、防火墙服务

systemctl start firewalld.service       #启动
systemctl stop firewalld.service        #关闭
systemctl restart firewalldservice      #重启
systemctl status firewalld.service      #显示防火墙的状态
systemctl enable firewalld.service      #开机时启动
systemctl disable firewalldservice      #开机时禁用
systemctlis-enabled firewalldservice    #查看防火墙是否开机启动
systemctl list-unit-files/grep enabled  #查看已启动的服务列表
systemctl--failed                       #查看启动失败的服务列表

二、防火墙配置

firewall-cmd --version
firewall-cmd --help
firewall-cmd --state
firewall-cmd --zone=public --list-ports  #查看所有打开的端口
firewall-cmd --get-active-zones          #查看区域信息
firewall-cmd -get-zone-of-interface=eth0 #查看指定接口所属区域
firewall-cmd --panic-on                  #拒绝所有包、取消拒绝状态、查看是否拒绝
firewall-cmd --panic-off 
firewall-cmd -query-panic
firewall-cmd--zone=public --add-port=3306/tcp --permanent     #开启3306端口,-permanent永久生效(区域public)
firewall-cmd --add-port=65001-65010/tcp --permanent      #永久增加65001-65010例外(全局) 
firewall-cmd--reload
firewall-cmd --zone=public -queryport=3306/tcp              #查看3306端口是否开放
firewall-cmd --zone=public --removeport=3306/tcp --permanent  #删除3306端口配置

三、配置文件

[root]# vi /etc/firewalld/zones/public.xml

<?xml version="1.0" encoding="utf-8"?>
<zone>
  <short>Public</short>
  <description>For use in public areas. You do not trust the other computers on networks to not harm your computer. Only selected incoming connections are accepted.</description>
  <service name="ssh"/>
  <service name="dhcpv6-client"/>
  <service name="cockpit"/>
  <port port="8080" protocol="tcp"/>
  <port port="8443" protocol="tcp"/>
  <port port="8175" protocol="tcp"/>
  <rule family="ipv4">
    <source address="123.x.x.14"/>
    <port protocol="tcp" port="10050-10051"/> ##可以开放端口地址范围"10050-10051",不单只限定一个端口
    <accept/>
  </rule>
  <rule family="ipv4">
    <source address="192.x.x.114"/>      ##放通指定ip,指定端口、协议
    <port protocol="tcp" port="80"/>
    <accept/>
  </rule>
  <rule family="ipv4">                        ##放通任意ip访问服务器的9527端口
    <port protocol="tcp" port="9527"/>
    <accept/>
  </rule>
</zone>

使用rm+grep

例如:删除当前文件夹下.c和 .h 文件以外的文件

rm -f `ls ./ | egrep -v "(.c$|.h$)"` 
  1. ls 列出所有文件;  
  2. egrep -v 查找所有不包含 .c和 .h的文件; .c$ - 以.c结尾的文件
  3. rm -f强制删除符合条件的文件

egrep - 查询多个关键字;

除了错误消息和使用消息不同以及 -s 标志的功能不同之外, egrep 命令与 grep 命令带 -E 标志是一样的。

您是第 68208 位访客