随堂笔记0403

张开发
2026/4/7 1:11:50 15 分钟阅读

分享文章

随堂笔记0403
负载监控计算机核心资源CPU 计算lscpu内存 缓存数据掉电丢失硬盘 持久化存储数据网络 传播数据[rootCentos01 wyj]# lscpu CPU(s): 2 型号名称 Intel(R) Core(TM) Ultra 9 185H CPU MHz 3072.000给系统加负载[rootCentos01 wyj]# md5sum /dev/zero [rootCentos01 wyj]# md5sum /dev/zero 查看使用情况 top 命令使用PCPU降序排序 M内存降序排序top - 10:14:36 up 2:32, 2 users, load average: 0.94, 0.24, 0.11 Tasks: 432 total, 5 running, 427 sleeping, 0 stopped, 0 zombie %Cpu(s): 96.7 us, 3.3 sy, 0.0 ni, 0.0 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st KiB Mem: 3869044 total, 2628880 used, 1240164 free, 1564 buffers KiB Swap: 4079612 total, 0 used, 4079612 free. 1672804 cached Mem ​ PID USER PR NI VIRT RES SHR S %CPU %MEM TIME COMMAND 12669 wyj 20 0 2065972 369100 9088 S 0.3 9.5 2:56.34 gnome-shell 1 root 20 0 53956 7008 2236 S 0.0 0.2 0:04.57 systemd 2 root 20 0 0 0 0 S 0.0 0.0 0:00.03 kthreaddCPU指标%Cpu(s): 96.7 us, 3.3 sy 100%内存指标KiB Mem: 3869044 total, 2628880 used, 1240164 free, 1564 buffers清理进程[rootCentos01 wyj]# kill 2262 [rootCentos01 wyj]# kill 2253 [1]- 已终止 md5sum /dev/zero [2] 已终止 md5sum /dev/zero [rootCentos01 wyj]#磁盘容量[rootCentos01 wyj]# df -h 文件系统 容量 已用 可用 已用% 挂载点 /dev/mapper/centos-root 46G 4.9G 41G 11% / devtmpfs 1.9G 0 1.9G 0% /dev tmpfs 1.9G 92K 1.9G 1% /dev/shm tmpfs 1.9G 9.0M 1.9G 1% /run tmpfs 1.9G 0 1.9G 0% /sys/fs/cgroup /dev/sda1 497M 119M 379M 24% /boot硬盘速度模拟下载[rootCentos01 ~]# wget http://192.168.42.100/02.%E7%B3%BB%E7%BB%9F%E9%95%9C%E5%83%8F/CentOS-7-x86_64-DVD-2207-02.isoiotop 查看每个进程的读写速度可以排序[rootCentos01 ~]# yum install -y iotop [rootCentos01 ~]# iotop查看硬盘整体速度硬盘名称sda 第一块sata接口硬盘硬盘 sdb[rootCentos01 ~]# sar -dp 1 Linux 3.10.0-123.el7.x86_64 (Centos01) 2026年04月02日 _x86_64_ (2 CPU) ​ 10时20分26秒 DEV tps rd_sec/s wr_sec/s avgrq-sz avgqu-sz await svctm %util 10时20分27秒 sda 6.93 95.05 0.00 13.71 0.01 0.86 0.86 0.59 10时20分27秒 centos-swap 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 10时20分27秒 centos-root 6.93 95.05 0.00 13.71 0.01 0.86 0.86 0.59 读写单位是k rd_sec/s wr_sec/s清理文件[rootCentos01 wyj]# rm CentOS-7-x86_64-DVD-2207-02.iso rm是否删除普通文件 CentOS-7-x86_64-DVD-2207-02.isoy网卡[rootCentos01 ~]# sar -n DEV 1 Linux 3.10.0-123.el7.x86_64 (Centos01) 2026年04月03日 _x86_64_ (2 CPU) ​ 09时18分35秒 IFACE rxpck/s txpck/s rxkB/s txkB/s rxcmp/s txcmp/s rxmcst/s 09时18分36秒 eno16777736 10.00 24.00 0.77 34.71 0.00 0.00 0.00 09时18分36秒 lo 0.00 0.00 0.00 0.00 0.00 0.00 0.00 ​ rxkB/s 接收 txkB/s 发送 1 1秒刷新一次服务管理pid为1的程序是systemd也是系统第一个进程负责操作系统整个资源的管理。 系统中服务也由systemd管理。systemctl 命令语法systemctl action service-name action: status start stop restart enalbe disable is-active is-enabled service-name: sshd firewalld mysqldsystemd与systemctl关系systemd 一直运行的程序守护进程systemctl 是给systemd下指令的工具人与机器之间交互使用。类比与web服务器httpd浏览器访问页面查看服务状态[rootCentos01 wyj]# systemctl status sshd sshd.service - OpenSSH server daemon Loaded: loaded (/usr/lib/systemd/system/sshd.service; enabled) Active: active (running) since 三 2026-04-01 18:28:31 CST; 16h ago Process: 1553 ExecStartPre/usr/sbin/sshd-keygen (codeexited, status0/SUCCESS) Main PID: 1565 (sshd) CGroup: /system.slice/sshd.service └─1565 /usr/sbin/sshd -D # 运行记录 4月 01 18:28:32 Centos01 sshd[1565]: Server listening on 0.0.0.0 port 22. 4月 01 18:28:32 Centos01 sshd[1565]: Server listening on :: port 22. 4月 01 18:31:51 Centos01 sshd[13180]: Accepted password for root from 192.16...h2 4月 01 18:31:51 Centos01 sshd[13184]: Accepted password for root from 192.16...h2 4月 01 18:31:58 Centos01 sshd[13390]: Accepted password for root from 192.16...h2 4月 01 18:31:59 Centos01 sshd[13395]: Accepted password for root from 192.16...h2 4月 02 09:18:39 Centos01 sshd[36914]: Accepted password for root from 192.16...h2 4月 02 09:18:40 Centos01 sshd[36918]: Accepted password for root from 192.16...h2 4月 02 10:20:08 Centos01 sshd[59861]: Accepted password for root from 192.16...h2 4月 02 10:20:09 Centos01 sshd[59868]: Accepted password for root from 192.16...h2 Hint: Some lines were ellipsized, use -l to show in full.重点关注Loaded: loaded (/usr/lib/systemd/system/sshd.service; enabled; vendor preset: enabled) 配置文件位置 /usr/lib/systemd/system/sshd.service 第一个enable 代表开机自动启动 第二个enable 暂不关注Active: active (running)停止服务[rootCentos01 wyj]# systemctl stop sshd [rootCentos01 wyj]# systemctl is-active sshd inactive [rootCentos01 wyj]# systemctl status sshd sshd.service - OpenSSH server daemon Loaded: loaded (/usr/lib/systemd/system/sshd.service; enabled) Active: inactive (dead) since 四 2026-04-02 11:14:54 CST; 52s ago使用工具再次连接连接不上去服务未启动。启动服务[rootCentos01 wyj]# systemctl start sshd [rootCentos01 wyj]# systemctl is-active sshd active使用工具再次连接能连接上服务启动。禁止sshd服务开机启动[rootCentos01 wyj]# systemctl disable sshd rm /etc/systemd/system/multi-user.target.wants/sshd.service [rootCentos01 wyj]# systemctl is-enabled sshd disabled重启验证机器启动后是否可以通过终端工具登录不行[rootCentos01 wyj]# reboot设置sshd服务开机启动[rootCentos01 wyj]# systemctl enable sshd ln -s /usr/lib/systemd/system/sshd.service /etc/systemd/system/multi-user.target.wants/sshd.service [rootCentos01 wyj]# systemctl is-enabled sshd enabled重启验证机器启动后是否可以通过终端工具登录行[rootCentos01 wyj]# reboot开发一个服务[rootcentos7 ~ 16:15:19]# vim /usr/local/bin/study #!/bin/bash # 第一行内容是脚本的 解释器声明shebang指定该脚本使用 /bin/bash 作为解释器执行。系统会根据这一行找到对应的 shell 程序来解析后续命令。 ​ # 启动一个无限循环while 是循环关键字true 是一个永远为真的条件因此这个循环会一直执行下去直到被外部终止如 CtrlC。 while true ​ # 循环体的开始标记do 和后面的 done 之间的内容是循环中重复执行的命令。 do # 执行 date 命令获取当前系统时间并通过 $(...) 捕获其输出将结果赋值给变量 DATE。 DATE$(date) # echo 命令输出字符串其中 $DATE 会被替换为变量的值 # 是追加重定向符号将输出内容追加到 /var/log/study.log 文件中 # 最终输出内容类似 Fri Oct 31 10:00:00 CST 2025: IM studying [ Linux ]。 echo $DATE: IM studying [ Linux ] /var/log/study.log # 让脚本暂停执行 5 秒sleep 命令用于延迟单位默认为秒避免循环执行过快。 sleep 5 ​ # 循环体的结束标记与前面的 while 和 do 配合标志着一次循环的结束。 done开发服务准备服务程序 /usr/local/bin/study准备服务配置文件 /etc/systemd/system/studyd.service (程序后面的ddaemon守护称呼)通知systemd 变化 systemctl daemon-reload激活服务 systemctl enable studyd --now复习 vim[rootcentos7 ~ 14:28:48]# cp /usr/lib/systemd/system/sshd.service /etc/systemd/system/studyd.service [rootcentos7 ~ 14:28:48]# vim /etc/systemd/system/studyd.service 1. :set nu 显示行号 2. 3,5d 【或者 光标移动到第三行d3d】 删除3-5行 3. 5,6d 删除5-6行 4. 6,9d 删除6-9行 5. /Open 搜索并定位到特定字符串位置 6. cw change word替换一个单词自动进入插入模式输入study按esc 7. /sbin 搜索C删除到最后并进入插入模式补全路径local/bin/study按esc 8. ZZ 保存退出。 ​ 最终文件内容如下 [Unit] Descriptionstudy server daemon ​ [Service] ExecStart/usr/local/bin/study ​ [Install] WantedBymulti-user.target ​ 补充 u 撤销上一步操作 ctrlr 重做上一步操作分析sshd建立连接流程操作步骤windows 管理员身份打开cmd执行arp -d 192.168.100.101(自己Linux服务IP开启wireshark捕捉vmware 8 nat网卡流量使用终端登录 Linux 服务分析 抓包结果OSI 七层模型。ssh工具使用windows中使用普通命令行操作1. ssh 192.168.100.101 2. ssh root192.168.100.101或者ssh wyj192.168.100.101 3-1. ssh wyj192.168.100.101 hostname 3-2. ssh wyj192.168.100.101 id为自己创建一个普通 wang 用户并设置密码[rootCentos01 ~]# useradd wang [rootCentos01 ~]# echo 123 | passwd --stdin wang 更改用户 wang 的密码 。 passwd所有的身份验证令牌已经成功更新。配置 ssh 工具配置文件如果.ssh目录不存在执行以下命令切用户 su - wang 要有- [wangCentos01 ~]$ ssh localhost # 然后ctrlc 停止即可准备配置文件[wangCentos01 ~]$ cp /etc/ssh/ssh_config .ssh/config [wangCentos01 ~]$ vim .ssh/config # 删除前19行 # 取消相应行注释 Host * # 新增 User 行指明默认登录用户 User root ​ # 首次登录不要提示输入yes/no(不要对主机key校验) # StrictHostKeyChecking ask StrictHostKeyChecking no验证[wangCentos01 ~]$ ssh 192.168.100.101 Warning: Permanently added 192.168.100.101 (ECDSA) to the list of known hosts. root192.168.100.101s password:ssh命令行传递密码工具 sshpass[rootCentos01 ~]# yum install -y sshpass确保之前连接过记得输入yes[wyjCentos01 root]$ ssh root192.168.100.101 The authenticity of host 192.168.100.101 (192.168.100.101) cant be established. ECDSA key fingerprint is db:95:2e:65:8b:15:dd:e1:a9:89:5f:2b:a3:bf:bc:49. Are you sure you want to continue connecting (yes/no)? yes Warning: Permanently added 192.168.100.101 (ECDSA) to the list of known hosts. ​ # 接下来传递密码登录 [wyjCentos01 root]$ sshpass -p 123456 ssh root192.168.100.101 id # 显示结果如下 uid0(root) gid0(root) 组0(root) 环境unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023配置使用秘钥登录window 终端工具使用秘钥登录Linux生成密钥对私钥和公钥将公钥复制给Linux服务器测试生成密钥对私钥和公钥xshell 为例 工具-用户秘钥管理者-生成打开界面基本上是下一步即可。 找到用户秘钥-属性-公钥标签复制公钥。例如ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAt9zyALQw0LFzUy8Q84NetuGDbixDaJWl83eieWGhOLQhC8iVxseetPB9yU42xXv7b1LJVcrlC3FbaxYue1xAmY3edBXmjQ/xne4rQ6G14NzqsIeXqjrNwP31tp2y5UeQ84rCx3cYcOXeTyqnsJFFMBeSU7AS0IajG5yPe026VdAo5wyAxVTkqKDcHiQwPoqLbviqNcqjyu87cn2tIKcgIi1NIXEnpyjHnqTewlIhGxVHx53j1R326Zod2ynKdhhqXU5rNsWEBkFwCDQ1vcF8FCtm7eQGncDcwkDbZ3rix01eqJipe5vkT1nYPUnmOZd/Co8HRBO4Nc9KBnw rsa 2048-20260406写入对方文件~/.ssh/authorized_keys[wyjCentos01 ~]$ vim .ssh/authorized_keys [wyjCentos01 ~]$ ll .ssh/authorized_keys -rw-rw-r-- 1 laoma laoma 394 4月 3 09:47 .ssh/authorized_keys [wyjCentos01 ~]$ chmod 600 .ssh/authorized_keys登录时候选择验证方式公钥并指定对应公钥。刚刚实现 windows 使用 laoma 用户秘钥登录 centos7 思考如何实现 windows 使用 root 用户秘钥登录 centos7[rootcentos7 ~ 10:19:01]# cat /home/laoma/.ssh/authorized_keys /root/.ssh/authorized_keysssh 工具配置文件 ~/.ssh/config用户级别给用户自己定制优先级更高 /etc/ssh/ssh_config系统全局级别默认设置针对系统中所有用户生效 sshd 服务配置文件 /etc/ssh/sshd_config针对sshd服务生效。控制root用户登录。因为所有Linux系统管理员都是root防止暴力破解。PermitRootLogin no 禁止登录 PermitRootLogin without-password 禁止使用密码登录[rootcentos7 ~ 10:21:06]# cp /etc/ssh/sshd_config /etc/ssh/sshd_config.20260403 [rootcentos7 ~ 10:30:16]# vim /etc/ssh/sshd_config 1. /Root定位。如果第一个搜索到的内容不是需要的使用nnext查找下一个。 2. yy 复制对应行p 粘贴到下一行。保留原有行 3. 自行删除第一# 4. w 跳转到yes位置cw 替换一个单词输入without-password按esc 5. ZZ 保存退出。 6. 重新加载服务 [rootcentos7 ~ 10:34:57]# systemctl restart sshd 7. 验证 ​ ## 禁止密码登录。 PasswordAuthentication no # 验证 DenyUsers, AllowUsers, DenyGroups,AllowGroups 例如AllowUsers laoma ​ [rootCentos01 ~]# man sshd_config 找PermitRootLogin支持参数 man 帮助 man 帮助 命令 --help 查询命令 如果查询配置文件如何写 man 配置文件名例如man sshd_config 搜索 Root/Root 软件包升级 # 查询软件包版本 [rootcentos7 ~ 11:01:38]# rpm -q openssh-server openssh-server-7.4p1-22.el7_9.x86_64 ​ # 查询可用版本 [rootcentos7 ~ 11:12:51]# yum list openssh-server --showduplicates 已加载插件fastestmirror, langpacks Loading mirror speeds from cached hostfile * base: mirrors.aliyun.com * extras: mirrors.aliyun.com * updates: mirrors.aliyun.com 已安装的软件包 openssh-server.x86_64 7.4p1-22.el7_9 anaconda 可安装的软件包 openssh-server.x86 _64 7.4p1-21.el7 base openssh-server.x86_64 7.4p1-22.el7_9 updates openssh-server.x86_64 7.4p1-23.el7_9 updates ​ # 升级到最新版本 [rootcentos7 ~ 11:15:25]# yum update -y openssh-server # 测试 参数 /etc/ssh/sshd_config 中参数 PermitRootLogin prohibit-password ​ 软件包升级 日志装centos7vmware 三种网络模式桥接主机NAT实验bash-completion 命令行补全 vim 高亮显示编辑器 open-vm-tools vmware 更好地控制虚拟机 lrzsz 上传和下载 unzip 解压zip rsync 同步sshpass 传递密码日志systemd-journal systemd子系统rsyslog 服务对应rsyslog 将日志记录到对应的文件中 | /var/log/messages | 大多数系统日志排除认证、邮件、定时任务、调试日志 | | /var/log/secure | 安全/认证相关日志如ssh登录、用户验证 | | /var/log/maillog | 邮件服务相关日志如sendmail/postfix | | /var/log/cron | 定时任务执行日志crontab/anacron | | /var/log/boot.log | 系统启动过程中的非syslog控制台消息 |实验一修改sshd_config内容导致错误 [rootcentos7 ~ 15:15:08]# tail -f /var/log/secure 新增加一个ssh连接日志更新内容如下 Apr 3 15:17:44 centos7 sshd[1292]: Accepted password for laoma from 10.1.8.1 port 5350 ssh2 Apr 3 15:17:44 centos7 sshd[1292]: pam_unix(sshd:session): session opened for user laoma by (uid0) ​ 断开连接日志更新内容如下 Apr 3 15:18:39 centos7 sshd[1292]: pam_unix(sshd:session): session closed for user laoma ​ 模拟sshd故障并排故。 模拟 [rootcentos7 ~ 15:20:35]# cp /etc/ssh/sshd_config{,.0403} [rootcentos7 ~ 15:20:43]# echo hello world /etc/ssh/sshd_config [rootcentos7 ~ 15:21:53]# systemctl restart sshd Job for sshd.service failed because the control process exited with error code. See systemctl status sshd.service and journalctl -xe for details. ​ # 根据提示 查看状态 [rootcentos7 ~ 15:22:22]# systemctl status sshd.service ● sshd.service - OpenSSH server daemon Loaded: loaded (/usr/lib/systemd/system/sshd.service; enabled; vendor preset: enabled) Active: activating (auto-restart) (Result: exit-code) since Fri 2026-04-03 15:22:22 CST; 27s ago Docs: man:sshd(8) man:sshd_config(5) Process: 1342 ExecStart/usr/sbin/sshd -D $OPTIONS (codeexited, status255) Main PID: 1342 (codeexited, status255) ​ Apr 03 15:22:22 centos7.laoma.cloud systemd[1]: sshd.service: main process exited, codeexited, status255/n/a Apr 03 15:22:22 centos7.laoma.cloud systemd[1]: Failed to start OpenSSH server daemon. Apr 03 15:22:22 centos7.laoma.cloud systemd[1]: Unit sshd.service entered failed state. Apr 03 15:22:22 centos7.laoma.cloud systemd[1]: sshd.service failed. ​ # 状态日志没有对应提示信息 ​ # 继续查看message日志 [rootcentos7 ~ 15:23:40]# tail /var/log/messages Apr 3 15:23:04 centos7 systemd: sshd.service failed. Apr 3 15:23:47 centos7 systemd: sshd.service holdoff time over, scheduling restart. Apr 3 15:23:47 centos7 systemd: Stopped OpenSSH server daemon. Apr 3 15:23:47 centos7 systemd: Starting OpenSSH server daemon... Apr 3 15:23:47 centos7 sshd: /etc/ssh/sshd_config: line 141: Bad configuration option: hello Apr 3 15:23:47 centos7 sshd: /etc/ssh/sshd_config: terminating, 1 bad configuration options # 发现 141 行有问题。 # 根据提示修复。 ​ [rootcentos7 ~ 15:25:50]# vim /etc/ssh/sshd_config # 注释最后一行 #hello world ​ [rootcentos7 ~ 15:26:10]# systemctl restart sshd [rootcentos7 ~ 15:26:17]# systemctl is-active sshd active ​ 补充 快速创建多个文件 [rootcentos7 ~ 15:20:05]# echo /etc/ssh/sshd_config-{1,2} [rootcentos7 ~ 15:20:05]# echo /etc/ssh/sshd_config-{1,2} /etc/ssh/sshd_config-1 /etc/ssh/sshd_config-2 [rootcentos7 ~ 15:20:11]# echo /etc/ssh/sshd_config-{,2} /etc/ssh/sshd_config- /etc/ssh/sshd_config-2 [rootcentos7 ~ 15:20:22]# echo /etc/ssh/sshd_config{,.0403} /etc/ssh/sshd_config /etc/ssh/sshd_config.0403 ​ 实验二移走sshd_config导致错误 # 故障2 [rootcentos7 ~ 16:04:31]# mv /etc/ssh/sshd_config /tmp [rootcentos7 ~ 15:39:13]# systemctl restart sshd Job for sshd.service failed because the control process exited with error code. See systemctl status sshd.service and journalctl -xe for details. [rootcentos7 ~ 15:46:05]# journalctl -e -u sshd ... ... Apr 03 15:45:32 centos7.laoma.cloud systemd[1]: Failed to start OpenSSH server daemon. Apr 03 15:45:32 centos7.laoma.cloud systemd[1]: Unit sshd.service entered failed state. Apr 03 15:45:32 centos7.laoma.cloud systemd[1]: sshd.service failed. Apr 03 15:46:05 centos7.laoma.cloud polkitd[676]: Registered Authentication Agent for unix-process:1504:240860 (syst Apr 03 15:46:05 centos7.laoma.cloud systemd[1]: Stopped OpenSSH server daemon. Apr 03 15:46:05 centos7.laoma.cloud systemd[1]: Starting OpenSSH server daemon... Apr 03 15:46:05 centos7.laoma.cloud sshd[1510]: /etc/ssh/sshd_config: No such file or directory Apr 03 15:46:05 centos7.laoma.cloud systemd[1]: sshd.service: main process exited, codeexited, status1/FAILURE Apr 03 15:46:05 centos7.laoma.cloud systemd[1]: Failed to start OpenSSH server daemon. Apr 03 15:46:05 centos7.laoma.cloud systemd[1]: Unit sshd.service entered failed state. Apr 03 15:46:05 centos7.laoma.cloud systemd[1]: sshd.service failed. Apr 03 15:46:05 centos7.laoma.cloud polkitd[676]: Unregistered Authentication Agent for unix-process:1504:240860 ​ # 发现 /etc/ssh/sshd_config: No such file or directory ​ # 查询文件哪个软件包提供 [rootcentos7 ~ 15:48:16]# yum provides /etc/ssh/sshd_config Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile * base: mirrors.aliyun.com * extras: mirrors.aliyun.com * updates: mirrors.aliyun.com openssh-server-7.4p1-21.el7.x86_64 : An open source SSH server daemon Repo : base Matched from: Filename : /etc/ssh/sshd_config ​ ​ ​ openssh-server-7.4p1-22.el7_9.x86_64 : An open source SSH server daemon Repo : updates Matched from: Filename : /etc/ssh/sshd_config ​ # yum-utils提供yumdownloader用于下载软件包 [rootcentos7 ~ 15:51:19]# yum install -y yum-utils [rootcentos7 ~ 15:51:19]# yumdownloader openssh-server Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile * base: mirrors.aliyun.com * extras: mirrors.aliyun.com * updates: mirrors.aliyun.com openssh-server-7.4p1-23.el7_9.x86_64.rpm | 459 kB 00:00:03 [rootcentos7 ~ 15:51:47]# ls openssh* openssh-server-7.4p1-23.el7_9.x86_64.rpm # rpm是一个特殊格式的文件里面文件通过 cpio 压缩。 ​ # 查看软件包中文件 [rootcentos7 ~ 15:56:17]# rpm2cpio openssh-server-7.4p1-23.el7_9.x86_64.rpm | cpio -t ./etc/pam.d/sshd ./etc/ssh/sshd_config ./etc/sysconfig/sshd ./usr/lib/systemd/system/sshd-keygen.service ./usr/lib/systemd/system/sshd.service ./usr/lib/systemd/system/sshd.socket ./usr/lib/systemd/system/sshd.service ./usr/lib64/fipscheck/sshd.hmac ./usr/libexec/openssh/sftp-server ./usr/sbin/sshd ./usr/sbin/sshd-keygen ./usr/share/man/man5/moduli.5.gz ./usr/share/man/man5/sshd_config.5.gz ./usr/share/man/man8/sftp-server.8.gz ./usr/share/man/man8/sshd.8.gz ./var/empty/sshd 1946 blocks ​ # 直接提取对应文件 [rootcentos7 ~ 15:56:47]# rpm2cpio openssh-server-7.4p1-23.el7_9.x86_64.rpm | cpio -id ./etc/ssh/sshd_config # 验证 [rootcentos7 ~ 15:57:23]# yum install -y tree [rootcentos7 ~ 15:57:18]# tree etc etc └── ssh └── sshd_config ​ 1 directory, 1 file # 将软件包里的sshd_config文件放入/etc/ssh [rootcentos7 ~ 16:18:57]# mv etc/ssh/sshd_config /etc/ssh [rootcentos7 ~ 15:57:51]# systemctl restart sshd ​ ​ # 补充 命令行快捷键 ctrlr 搜索历史命令回车执行。

更多文章