linux作业--第八周
1、创建私有CA并进行证书申请。
配置文件存放路径 /etc/pki/tls/openssl.cnf
[ CA_default ]
dir = /etc/pki/CA # Where everything is kept
certs = $dir/certs # Where the issued certs are kept
crl_dir = $dir/crl # Where the issued crl are kept
database = $dir/index.txt # database index file.
#unique_subject = no # Set to 'no' to allow creation of
# several ctificates with same subject.
new_certs_dir = $dir/newcerts # default place for new certs.
certificate = $dir/cacert.pem # The CA certificate
serial = $dir/serial # The current serial number
crlnumber = $dir/crlnumber # the current crl number
# must be commented out to leave a V1 CRL
crl = $dir/crl.pem # The current CRL
private_key = $dir/private/cakey.pem# The private key
RANDFILE = $dir/private/.rand # private random number file

创建CA所需要的文件
#生成证书索引数据库文件
touch /etc/pki/CA/index.txt
#指定第一个颁发证书的序列号
echo 01 > /etc/pki/CA/serial
生成CA私钥
cd /etc/pki/CA/
(umask 066; openssl genrsa -out private/cakey.pem 2048)

生成CA自签名证书
# openssl req -new -x509 -key /etc/pki/CA/private/cakey.pem -days 3650 -out /etc/pki/CA/cacert.pem

[root@localhost CA]# openssl x509 -in cacert.pem -noout -text
将证书文件的base64编码转换为一个易读的格式查看证书文件

将证书文件cacert.pem传至windows桌面,修改文件名为cacert.pem.crt,双击可以看到下面显示
[root@localhost CA]# sz cacert.pem

用户生成私钥和证书申请
生成私钥
[root@localhost data]# mkdir app1
[root@localhost app1]# (umask 066; openssl genrsa -out /data/app1/app1.key 2048)
Generating RSA private key, 2048 bit long modulus
....+++
................................................................................................................................................+++
e is 65537 (0x10001)
生成证书申请文件
[root@localhost app1]# openssl req -new -key /data/app1/app1.key -out /data/app1/app1.csr

CA颁发证书
[root@localhost app1]# openssl ca -in /data/app1/app1.csr -out /etc/pki/CA/certs/app1.crt -days 1000


验证指定编号对应证书的有效性
[root@localhost app1]# openssl ca -status 01
Using configuration from /etc/pki/tls/openssl.cnf
01=Valid (V)
导出CA证书


至此CA颁发证书的整个过程已经完成
2、总结ssh常用参数、用法
常见参数:
- -p port #远程服务器监听的端口
- -b #指定连接的源IP
- -v #调试模式
- -C #压缩方式
- -X #支持x11转发
- -t #强制伪tty分配,如:ssh -t remoteserver1 ssh -t remoteserver2 ssh remoteserver3
用法:
ssh命令是ssh客户端,允许实现对远程系统经验证地加密安全访问。ssh客户端配置文件是:/etc/ssh/ssh_config
ssh命令配合的常见选项:
-p port:远程服务器监听的端口
ssh 192.168.42.200 -p 2222
-b 指定连接的源IP
ssh 192.168.42.200 -p 2222 -b 192.168.42.5
-v 调试模式
ssh 192.168.42.200 -p 2222 -v
-C 压缩方式
-X 支持x11转发
支持将远程linux主机上的图形工具在当前设备使用
-t 强制伪tty分配,如:ssh -t remoteserver1 ssh -t remoteserver2 ssh remoteserver3
ssh -t 192.168.42.201 ssh -t 192.168.42.202 ssh 192.168.42.200
-o option 如:-o StrictHostKeyChecking=no
-i <file> 指定私钥文件路径,实现基于key验证,默认使用文件: ~/.ssh/id_dsa, ~/.ssh/id_ecdsa, ~/.ssh/id_ed25519,~/.ssh/id_rsa等
3、总结sshd服务常用参数。
服务器端的配置文件: /etc/ssh/sshd_config
常用参数:
Port #端口号
ListenAddress ipLoginGraceTime 2m #宽限期
PermitRootLogin yes #默认ubuntu不允许root远程ssh登录
StrictModes yes #检查.ssh/文件的所有者,权限等
MaxAuthTries 6
MaxSessions 10 #同一个连接最大会话
PubkeyAuthentication yes #基于key验证
PermitEmptyPasswords no #空密码连接
PasswordAuthentication yes #基于用户名和密码连接
GatewayPorts no
ClientAliveInterval 10 #单位:秒
ClientAliveCountMax 3 #默认3
UseDNS yes #提高速度可改为no
GSSAPIAuthentication yes #提高速度可改为no
MaxStartups #未认证连接最大值,默认值10
Banner /path/file
#以下设置可以限制可登录用户:
AllowUsers user1 user2 user3
DenyUsers
AllowGroups
4、搭建dhcp服务,实现ip地址申请分发
注:DHCP服务的软件:
dhcp(CentOS 7 之前版本) 或 dhcp-server(CentOS 8 中的包名)
本实验在centos7完成
- 安装软件包
yum install -y dhcp 或 yum install -y dhcp-server (centos8)
- 修改配置文件
[root@localhost ~]# cp /usr/share/doc/dhcp-4.2.5/dhcpd.conf.example /etc/dhcp/dhcpd.conf
vim /etc/dhcp/dhcpd.conf
option domain-name "example.org";
option domain-name-servers 180.76.76.76, 114.114.114.114; #DNS服务
default-lease-time 86400; #地址租期
max-lease-time 106400; #地址最大租期
subnet 192.168.42.0 netmask 255.255.255.0 {
range 192.168.42.100 192.168.42.120; #地址池
option routers 192.168.42.1; #网关
}
注:将地址与MAC地址进行绑定
host test {
hardware ethernet 00:0c:29:b1:39:7a;
fixed-address 192.168.42.125;
}

- 重启服务
systemctl restart dhcpd
- 客户端网卡配置
[root@localhost ~]# cat /etc/sysconfig/network-scripts/ifcfg-eth0
# Generated by dracut initrd
NAME="eth0"
DEVICE="eth0"
ONBOOT=yes
NETBOOT=yes
UUID="71bb1423-8fef-4074-88fd-30cb062bdde7"
IPV6INIT=yes
BOOTPROTO=dhcp
TYPE=Ethernet
- 获取地址
dhclient -d

- 查看获取到的地址

linux作业--第八周的更多相关文章
- bug终结者 团队作业第八周
bug终结者 团队作业第八周 本次任务 素材提供及编辑:20162328 蔡文琛 博客修改完善:20162322 朱娅霖 "bug终结者" 宏伟蓝图 UML 手绘底稿 用例图 选项 ...
- 20135302魏静静——linux课程第八周实验及总结
linux课程第八周实验及总结 实验及学习总结 1. 进程切换在内核中的实现 linux中进程切换是很常见的一个操作,而这个操作是在内核中实现的. 实现的时机有以下三个时机: 中断处理过程(包括时钟中 ...
- 补交作业-第八周PSP
一.表格 C(分类) C(内容) S(开始时间) ST(结束时间) I(打断时间) △(净工作时间) 讨论 用户界面 9:30 10:40 15 55 编码 编码 13:20 16:30 10 180 ...
- Linux内核分析作业第八周
进程的切换和系统的一般执行过程 一.进程调度的时机 中断处理过程(包括时钟中断.I/O中断.系统调用和异常)中,直接调用schedule(),或者返回用户态时根据need_resched标记调用sch ...
- linux作业--第五周
1.简述osi七层模型和TCP/IP五层模型 一.OSI参考模型 (1) OSI的来源 OSI(Open System Interconnect),即开放式系统互联. 一般都叫OSI参考模型,是ISO ...
- linux作业--第三周
1.统计出/etc/passwd文件中其默认shell为非/sbin/nologin的用户个数,并将用户都显示出来 [root@localhost ~]# cat /etc/passwd | grep ...
- Linux入门-第八周
1.用shell脚本实现自动登录机器 #!/usr/bin/expectset ip 192.168.2.192set user rootset password rootspawn ssh $use ...
- linux作业--第十一周
1. 导入hellodb.sql生成数据库 (1) 在students表中,查询年龄大于25岁,且为男性的同学的名字和年龄 (2) 以ClassID为分组依据,显示每组的平均年龄 (3) 显示第2题中 ...
- linux作业--第十周
1.在阿里云服务器搭建openv-p-n(有条件的同学再做) 2.通过编译.二进制安装MySQL5.7 编译安装MySQL5.7 安装相关包 yum -y install libaio numactl ...
随机推荐
- ARC084F - XorShift
有两种解法,这里都放一下. 解法一 首先易知异或运算可以视作是 \(\mathbb{F}_2\) 意义下的每一位独立的加法. 因此我们可以考虑对于每个二进制数 \(s\) 构造一个多项式 \(F(x) ...
- CentOS 7中的系统语言包及UTF-8、en_US.UTF-8和zh_CN.UTF-8的区别
UTF-8.en_US.UTF-8和zh_CN.UTF-8的区别 en_US.UTF-8.zh_CN.UTF-8叫做字符集,就是说'A'.'B'.'中'.'国'等对应的整数值,en_US.UTF-8只 ...
- JSP、Servlet和Spring MVC
感谢原博主!!!https://blog.csdn.net/whut2010hj/article/details/80874008 版权声明:本文为博主原创文章,遵循CC 4.0 BY版权协议,转载请 ...
- HOOK API(二) —— HOOK自己程序的 MessageBox
转载来源:https://www.cnblogs.com/hookjc/ 0x00 前言 以下将给出一个简单的例子,作为HOOK API的入门.这里是HOOK 自己程序的MessageBox,即将自己 ...
- 使用Java开发桌面即时通讯程序遇到的问题
项目:https://www.lking.top/?p=87 1. JPanel面板绘制背景图片问题. 参考大佬:https://www.jb51.net/article/101516.htm 本项目 ...
- Centos8安装virtualbox
一.执行以下命令并启用 VirtualBox 和 EPEL 包仓库 dnf config-manager --add-repo=https://download.virtualbox.org/virt ...
- 一招教你IDEA中Java程序如何打包,以及打包后如何运行
前言 编写程序 程序打包 测试运行 IDEA作为目前按最主流的Java程序项目编写工具,越来越受到开发人员的青睐.idea因为其五花八门的功能,让你在开发过程中效率显著提高.那么对于初学者来说,如何通 ...
- Python中set集合常用操作
功能 Python符号 Python方法 备注 交集 & intersection, intersection_update &:取两者交集>>> set3 = se ...
- Ubuntu18配置静态IP地址
1. 记住网卡名称 ifconfig 2. 记住网关地址 netstat -rn 3. 配置静态IP 注意:Ubuntu18固定IP的方式跟Ubuntu18之前版本的的配置方式不同, Ubuntu18 ...
- 非极大值抑制算法(Python实现)
date: 2017-07-21 16:48:02 非极大值抑制算法(Non-maximum suppression, NMS) 算法原理 非极大值抑制算法的本质是搜索局部极大值,抑制非极大值元素. ...