Linux之ssl配置,nfs挂载,autofs自动挂载及https中ssl层的握手协议流程(超详解)

本文档详细介绍了如何配置Apache服务器以实现HTTPS访问,包括安装mod_ssl模块、创建SSL配置文件、设置首页内容和宽容模式。同时,还涵盖了Apache CGI程序的配置,以及NFS服务的设置,包括共享目录、权限管理和用户映射。最后,讨论了HTTPS中SSL层的握手协议流程,从client_hello到握手结束的各个步骤。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

目录

1.配置使用ssl完成https访问apache服务器

1.mod_ssl 是一种以 openssl 的工具箱为基础专门为 apache webserver 提供密码保护的软件。

2.创建myssl.conf配置文件

3.首先创建首页显示内容所需文件及目录

4. 强制改为宽容模式重启httpd服务

2.配置访问apache的cgi程序

 1.首先进入cgi-bin目录下,里面的文件为可执行文件

 2,访问https://192.168.40.122/cgi-bin/test.cgi​编辑

3.nfs挂载 a、开放/nfs/shared目录,供所有用户查询资料;

1.首先在服务器上下载所需程序

 2. 创建主配置文件并配置

3.创建目录及文件

   4.使用chmod开放所有权限

 5.登录客户端手动挂载 ​编辑

b、开放/nfs/upload目录,该目录为192.168.xxx.0/24网段的主机的数据上传目录,并将所有该网段主机上传文件的所属者和所属组映射为nfs-upload,其UID和GID为2001;

1.首先创建upload目录并创建文件

2. 在主配置文件中添加规则​编辑

3.创建用户和组并指定uid/gid 

 4.重新加载配置​编辑

 5.在客户端远程连接

 6.客户端创建文件

 7.查看文件所属者所属组和uid/gid

​ c、将/home/tom(该目录为uid=1111,gid=1111的tom用户的家目录)目录仅共享给192.168.xxx.128这台主机上的jerry用户,jerry对该目录具有访问、新建和删除文件的权限。

 1.创建tom和组并指定uid/gid

2. 在主配置文件中添加规则

​3.重启服务​编辑

 4.在客户端创建jerry并添加192.168.40.128这个ip

 5.使用root用户挂载并切换到jerry创建文件

​4.autofs自动挂载  远程nfs服务器要的目录为/nfs/autofs  客户端的的挂载目录/data1/autofs  且设置自动卸载时间为60秒

 1.先在客户端进入主配置文件中

​2.在服务器中添加挂载

 3.在服务器上重启服务

 4.在客户端重启autofs后触发条件自动挂载

​5:https中ssl层的握手协议流程

 1. client_hello

2. server_hello

4. client_key_exchange / change_cipher_spec / encrypted_handshake_message

5. change_cipher_spec / encrypted_handshake_message

6. 握手结束


1.配置使用ssl完成https访问apache服务器

1.mod_ssl 是一种以 openssl 的工具箱为基础专门为 apache webserver 提供密码保护的软件。

[root@rhcsa tls]# yum install mod_ssl -y
Updating Subscription Management repositories.
Unable to read consumer identity

This system is not registered with an entitlement server. You can use subscription-manager to register.

Repository AppStream is listed more than once in the configuration
BaseOS                                          2.7 MB/s | 2.8 kB     00:00    
Dependencies resolved.
================================================================================
 Package  Arch    Version                                      Repository  Size
================================================================================
Installing:
 mod_ssl  x86_64  1:2.4.37-43.module_el8.5.0+1022+b541f3b1     AppStream  136 k

Transaction Summary
================================================================================
Install  1 Package

Total download size: 136 k
Installed size: 266 k
Downloading Packages:
mod_ssl-2.4.37-43.module_el8.5.0+1022+b541f3b1. 312 kB/s | 136 kB     00:00    
--------------------------------------------------------------------------------
Total                                           312 kB/s | 136 kB     00:00     
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                        1/1 
  Installing       : mod_ssl-1:2.4.37-43.module_el8.5.0+1022+b541f3b1.x86   1/1 
  Running scriptlet: mod_ssl-1:2.4.37-43.module_el8.5.0+1022+b541f3b1.x86   1/1 
  Verifying        : mod_ssl-1:2.4.37-43.module_el8.5.0+1022+b541f3b1.x86   1/1 
Installed products updated.

Installed:
  mod_ssl-1:2.4.37-43.module_el8.5.0+1022+b541f3b1.x86_64                       

Complete!

2.创建myssl.conf配置文件

在里面如下所配置

[root@rhcsa conf.d]# cd /etc/httpd/conf.d/
[root@rhcsa conf.d]# vim myssl.conf 

在<VirtualHost>里面配置自己生成的SSL证书 

3.首先创建首页显示内容所需文件及目录

[root@rhcsa www]# mkdir myssl
[root@rhcsa www]# cd myssl/
[root@rhcsa myssl]# echo "This is my first https page" > index.html
[root@rhcsa myssl]# ll
total 4
-rw-r--r--. 1 root root 28 Jul 29 10:40 index.html

4. 强制改为宽容模式重启httpd服务

[root@rhcsa conf.d]# setenforce 0
[root@rhcsa conf.d]# systemctl restart httpd


2.配置访问apache的cgi程序

 1.首先进入cgi-bin目录下,里面的文件为可执行文件

[root@rhcsa cgi-bin]# cd /var/www/cgi-bin/
[root@rhcsa cgi-bin]# vim test.cgi

 2,访问https://192.168.40.122/cgi-bin/test.cgi

3.nfs挂载
 a、开放/nfs/shared目录,供所有用户查询资料;

1.首先在服务器上下载所需程序

[root@rhcsa data]# yum install rpcbind nfs-utils -y

 2. 创建主配置文件并配置

[root@rhcsa ~]# vim /etc/exports

3.创建目录及文件

[root@rhcsa data]# mkdir /nfs/shared -p
[root@rhcsa data]# cd /nfs/shared/
[root@rhcsa shared]# echo "Hello" > test.txt

   4.使用chmod开放所有权限

[root@rhcsa ~]# ls -ld /nfs/
drwxrwxrwx. 3 root root 20 Jul 29 18:00 nfs/
[root@rhcsa ~]# ls -ld /nfs/shared/
drwxrwxrwx. 2 root root 22 Jul 29 18:00 nfs/shared/
[root@rhcsa ~]# ls -ld /nfs/shared/test.txt 
-rwxrwxrwx. 1 root root 7 Jul 29 18:00 nfs/shared/test.txt

 5.登录客户端手动挂载 

b、开放/nfs/upload目录,该目录为192.168.xxx.0/24网段的主机的数据上传目录,并将所有该网段主机上传文件的所属者和所属组映射为nfs-upload,其UID和GID为2001;

1.首先创建upload目录并创建文件

2. 在主配置文件中添加规则

3.创建用户和组并指定uid/gid 

[root@rhcsa upload]# groupadd -r nfs-upload -g2001
[root@rhcsa upload]# useradd nfs-upload -g2001 -u2001

 4.重新加载配置

 5.在客户端远程连接

 6.客户端创建文件

[root@rhce upload]# touch test2.txt

 7.查看文件所属者所属组和uid/gid

  c、将/home/tom(该目录为uid=1111,gid=1111的tom用户的家目录)目录仅共享给192.168.xxx.128这台主机上的jerry用户,jerry对该目录具有访问、新建和删除文件的权限。

 1.创建tom和组并指定uid/gid

[root@rhcsa nfs]# groupadd -r tom -g1111
[root@rhcsa nfs]# useradd tom -g1111 -u1111
[root@rhcsa nfs]# passwd tom 
New password: 
Retype new password: 
passwd: all authentication tokens updated successfully.

2. 在主配置文件中添加规则

[root@rhcsa tom]# vim /etc/exports

 3.重启服务

 4.在客户端创建jerry并添加192.168.40.128这个ip

 5.使用root用户挂载并切换到jerry创建文件


4.autofs自动挂载
  远程nfs服务器要的目录为/nfs/autofs
  客户端的的挂载目录/data1/autofs
  且设置自动卸载时间为60秒

 1.先在客户端进入主配置文件中

[root@rhce ~]# vim /etc/auto.master

/data1 为本地挂载点的主目录    /etc/auto.mynfs为配置文件 

  2.在服务器中添加挂载

[root@rhcsa ~]# vim /etc/exports

 3.在服务器上重启服务

 4.在客户端重启autofs后触发条件自动挂载


5:https中ssl层的握手协议流程

 1. client_hello

客户端发起请求,以明文传输请求信息,包含版本信息,加密套件候选列表,压缩算法候选列表,随机数,扩展字段等信息,相关信息如下:

(1) 支持的最高TSL协议版本version,从低到高依次 SSLv2,SSLv3,TLSv1,TLSv1.1,TLSv1.2,TLSv1.3。

(2) 客户端支持的加密套件 cipher suites 列表。

(3) 支持的压缩算法 compression methods 列表,用于后续的信息压缩传输。

(4) 随机数 random_C,用于后续的密钥的生成。

(5) 扩展字段 extensions,支持协议与算法的相关参数以及其它辅助信息等。 

2. server_hello

 server_hello, 服务端返回协商的信息结果,包括选择使用的协议版本 version,选择的加密套件 cipher suite,选择的压缩算法 compression method、随机数 random_S 等,其中随机数用于后续的密钥协商。

3. 证书校验

客户端验证证书的合法性,如果验证通过才会进行后续通信,否则根据错误情况不同做出提示和操作。

4. client_key_exchange / change_cipher_spec / encrypted_handshake_message

(1) client_key_exchange,合法性验证通过之后,客户端计算产生随机数字 Pre-master,并用证书公钥加密,发送给服务器。

(2) change_cipher_spec,客户端通知服务器后续的通信都采用协商的通信密钥和加密算法进行加密通信。

(3) encrypted_handshake_message,结合之前所有通信参数的 hash 值与其它相关信息生成一段数据,采用协商密钥 session secret 与算法进行加密,然后发送给服务器用于数据与握手验证。

5. change_cipher_spec / encrypted_handshake_message

(1) 服务器用私钥解密加密的 Pre-master 数据。

(2) 计算之前所有接收信息的 hash 值,然后解密客户端发送的 encrypted_handshake_message,验证数据和密钥正确性。

(3) change_cipher_spec, 验证通过之后,服务器同样发送 change_cipher_spec 以告知客户端后续的通信都采用协商的密钥与算法进行加密通信。

(4) encrypted_handshake_message, 服务器也结合所有当前的通信参数信息生成一段数据并采用协商密钥 session secret 与算法加密并发送到客户端。(将随机密码加密的数据响应给客户端)

6. 握手结束

客户端计算所有接收信息的 hash 值,并采用协商密钥解密 encrypted_handshake_message,验证服务器发送的数据和密钥,验证通过则握手完成。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Gur.

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值