网络安全技术与应用:远程控制与数据库安全

news2025/1/16 11:41:19

实验准备

软件:VMware Workstation Pro
虚拟机:Red Hat Enterprise Linux 7 服务器,Red Hat Enterprise Linux 7 客户端
网络模式:NAT模式

1、配置服务器及客户端网络

服务器IP

客户端IP

测试相互通信

在客户机上设置镜像,配置yum源

[root@localhost 桌面]# mkdir /mnt/cdrom
[root@localhost 桌面]# mount /dev/sr0 /mnt/cdrom/
mount: /dev/sr0 写保护,将以只读方式挂载
[root@localhost 桌面]# vim /etc/yum.repos.d/a.repo
[root@localhost 桌面]# cat /etc/yum.repos.d/a.repo
[a]
name=a
baseurl=file:///mnt/cdrom
enable=1
gpgcheck=0

在完成MariaDB数据库软件程序的安装并确保其成功启动后,我们建议先不要急于使用它。为了保障数据库的安全性和稳定运行,首要任务是进行初始化操作。该初始化流程包含以下五个关键步骤:
设置root管理员在数据库中的密码值(该密码并非root管理员在系统中的密码,密码值默认为空,直接回车即可)。

设置root管理员在数据库中的专有密码。

删除匿名用户,并使用root管理员从远程登录数据库,以确保数据库上运行的业务的安全性。

删除默认的测试数据库,取消测试数据库的一系列访问权限。

刷新授权列表,让初始化的设定立即生效。

[root@localhost 桌面]# mysql_secure_installation 
/usr/bin/mysql_secure_installation:行379: find_mysql_client: 未找到命令

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!

In order to log into MariaDB to secure it, we'll need the current
password for the root user.  If you've just installed MariaDB, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.

Enter current password for root (enter for none): (默认为空)
OK, successfully used password, moving on...

Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorisation.

Set root password? [Y/n] y (设置管理员密码)
New password: 
Re-enter new password: 
Password updated successfully!
Reloading privilege tables..
 ... Success!


By default, a MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB without having to have a user account created for
them.  This is intended only for testing, and to make the installation
go a bit smoother.  You should remove them before moving into a
production environment.

Remove anonymous users? [Y/n] y (删除匿名账户)
 ... Success!

Normally, root should only be allowed to connect from 'localhost'.  This
ensures that someone cannot guess at the root password from the network.

Disallow root login remotely? [Y/n] y (禁止管理员从远程登录)
 ... Success!

By default, MariaDB comes with a database named 'test' that anyone can
access.  This is also intended only for testing, and should be removed
before moving into a production environment.

Remove test database and access to it? [Y/n] y (删除测试数据库及其访问权限)
 - Dropping test database...
 ... Success!
 - Removing privileges on test database...
 ... Success!

Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.

Reload privilege tables now? [Y/n] y (刷新授权表,让初始化后的设定立即生效)
 ... Success!

Cleaning up...

All done!  If you've completed all of the above steps, your MariaDB
installation should now be secure.

Thanks for using MariaDB!

在众多生产环境的实践中,站库分离技术(即将网站与数据库部署于不同的服务器)被广泛应用以确保系统的高可用性和安全性。当需要为root管理员提供远程访问数据库的权限时,我们需要在初始化过程中制定相应的策略,以允许root管理员从远程地址进行连接。此外,为了保障数据库服务的安全,还需配置防火墙规则,确保其对数据库服务程序(如MySQL,默认占用3306端口)的访问请求进行放行。在防火墙策略中,这类服务通常被统一标识为“mysql”。

[root@localhost 桌面]# firewall-config

首次登录MariaDB数据库。为了管理数据库,我们将使用mysql命令。在这个命令中,-u参数用于指定以root管理员的身份进行登录,-p用来验证该用户在数据库中的密码值,以确保登录的安全性。

[root@localhost 桌面]# mysql -u root -p
Enter password:  (输入刚刚设置的密码)
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 11
Server version: 5.5.35-MariaDB MariaDB Server

Copyright (c) 2000, 2013, Oracle, Monty Program Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> SHOW databases;          //查看数据库管理系统中当前都有哪些数据库
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
+--------------------+
3 rows in set (0.00 sec)

MariaDB [(none)]> SET password = PASSWORD('hnswjj');  //使用数据库命令将root管理员在数据库管理系统中的密码值修改为hnswjj
Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> exit
Bye
(使用原密码redhat尝试登陆,登陆失败)
[root@localhost 桌面]# mysql -u root -p
Enter password: 
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)

(使用新密码hnswjj尝试登陆,登陆成功,创建用户student,admin,jack)
[root@localhost 桌面]# mysql -u root -p
Enter password: 
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 13
Server version: 5.5.35-MariaDB MariaDB Server

Copyright (c) 2000, 2013, Oracle, Monty Program Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> CREATE USER student@localhost IDENTIFIED BY 'redhat';
Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> CREATE USER admin@localhost IDENTIFIED BY 'redhat';
Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> CREATE USER jack@localhost IDENTIFIED BY 'redhat';
Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> use mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
MariaDB [mysql]> SELECT HOST,USER,PASSWORD FROM user WHERE USER="student";
+-----------+---------+-------------------------------------------+
| HOST      | USER    | PASSWORD                                  |
+-----------+---------+-------------------------------------------+
| localhost | student | *84BB5DF4823DA319BBF86C99624479A198E6EEE9 |
+-----------+---------+-------------------------------------------+
1 row in set (0.00 sec)

MariaDB [mysql]> SELECT HOST,USER,PASSWORD FROM user WHERE USER="admin";
+-----------+-------+-------------------------------------------+
| HOST      | USER  | PASSWORD                                  |
+-----------+-------+-------------------------------------------+
| localhost | admin | *84BB5DF4823DA319BBF86C99624479A198E6EEE9 |
+-----------+-------+-------------------------------------------+
1 row in set (0.00 sec)

MariaDB [mysql]> SELECT HOST,USER,PASSWORD FROM user WHERE USER="jack";
+-----------+------+-------------------------------------------+
| HOST      | USER | PASSWORD                                  |
+-----------+------+-------------------------------------------+
| localhost | jack | *84BB5DF4823DA319BBF86C99624479A198E6EEE9 |
+-----------+------+-------------------------------------------+
1 row in set (0.00 sec)

MariaDB [mysql]> SHOW GRANTS FOR student@localhost;
+----------------------------------------------------------------------------------------------------------------+
| Grants for student@localhost                                                                                   |
+----------------------------------------------------------------------------------------------------------------+
| GRANT USAGE ON *.* TO 'student'@'localhost' IDENTIFIED BY PASSWORD '*84BB5DF4823DA319BBF86C99624479A198E6EEE9' |
+----------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)

查看student用户权限,并针对mysql数据库中的user表单向用户luke授予查询、更新、删除以及插入等权限;

MariaDB [mysql]> GRANT SELECT,UPDATE,DELETE,INSERT ON mysql.user TO student@localhost;
Query OK, 0 rows affected (0.00 sec)

MariaDB [mysql]> SHOW GRANTS FOR student@localhost;
+----------------------------------------------------------------------------------------------------------------+
| Grants for student@localhost                                                                                   |
+----------------------------------------------------------------------------------------------------------------+
| GRANT USAGE ON *.* TO 'student'@'localhost' IDENTIFIED BY PASSWORD '*84BB5DF4823DA319BBF86C99624479A198E6EEE9' |
| GRANT SELECT, INSERT, UPDATE, DELETE ON `mysql`.`user` TO 'student'@'localhost'                                |
+----------------------------------------------------------------------------------------------------------------+
2 rows in set (0.00 sec)

MariaDB [mysql]> exit;
Bye

mysqldump命令用于备份数据库数据,格式为“mysqldump [参数] [数据库名称]”。其中参数与mysql命令大致相同,-u参数用于定义登录数据库的用户名称,-p参数表示密码提示符。下面将hnswjjxy数据库中的内容导出为一个文件,并保存到root管理员的家目录中:

[root@localhost ~]# mysql -u root -p
Enter password: 
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 15
Server version: 5.5.35-MariaDB MariaDB Server

Copyright (c) 2000, 2013, Oracle, Monty Program Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> CREATE DATABASE hnswjjxy;
Query OK, 1 row affected (0.00 sec)

MariaDB [(none)]> exit;
Bye
[root@localhost ~]# mysqldump -u root -p hnswjjxy > /root/hnswjjxy.dump
Enter password: 
[root@localhost ~]# cd /root
[root@localhost ~]# ls
anaconda-ks.cfg  initial-setup-ks.cfg  模板  图片  下载  桌面
hnswjjxy.dump    公共                  视频  文档  音乐

然后进入MariaDB数据库管理系统,彻底删除hnswjjxy数据库,这样mybook数据表单也将被彻底删除。

[root@localhost ~]# mysql -u root -p
Enter password: 
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 17
Server version: 5.5.35-MariaDB MariaDB Server

Copyright (c) 2000, 2013, Oracle, Monty Program Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> DROP DATABASE hnswjjxy;
Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> SHOW databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
+--------------------+
3 rows in set (0.00 sec)

远程控制服务ssh配置

服务器

客户端

[root@localhost ~]# ifconfig
eno16777736: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.159.134  netmask 255.255.255.0  broadcast 192.168.159.255
        inet6 fe80::20c:29ff:fe48:38d  prefixlen 64  scopeid 0x20<link>
        ether 00:0c:29:48:03:8d  txqueuelen 1000  (Ethernet)
        RX packets 939  bytes 66043 (64.4 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 275  bytes 26173 (25.5 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 0  (Local Loopback)
        RX packets 17  bytes 1808 (1.7 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 17  bytes 1808 (1.7 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

[root@localhost ~]# ssh 192.168.159.133
The authenticity of host '192.168.159.133 (192.168.159.133)' can't be established.
ECDSA key fingerprint is 01:e1:e1:a1:fe:89:18:b6:3d:ba:d4:a3:19:f3:1a:f9.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '192.168.159.133' (ECDSA) to the list of known hosts.
root@192.168.159.133's password: 
Last failed login: Thu May 23 15:16:42 CST 2024 from 192.168.159.134 on ssh:notty
There was 1 failed login attempt since the last successful login.
Last login: Thu May 23 14:07:18 2024
[root@localhost ~]# ifconfig     //注:此时已远程登陆至服务器,故ifconfig命令看到的是服务器ip.
eno16777736: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.159.133  netmask 255.255.255.0  broadcast 192.168.159.255
        inet6 fe80::20c:29ff:feb5:e726  prefixlen 64  scopeid 0x20<link>
        ether 00:0c:29:b5:e7:26  txqueuelen 1000  (Ethernet)
        RX packets 1026  bytes 77681 (75.8 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 297  bytes 30414 (29.7 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 0  (Local Loopback)
        RX packets 13  bytes 1360 (1.3 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 13  bytes 1360 (1.3 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
[root@localhost ~]# exit
登出
Connection to 192.168.159.133 closed.

打开服务器sshd服务配置文件,将第48行的参数设置为禁止root管理员远程登录;

[root@localhost 桌面]# vim /etc/ssh/sshd_config 

[root@localhost ~]# systemctl restart sshd.service

使用客户端远程登陆,提示登陆成功;

使用客户端远程传输文件至服务器的/home目录

[root@localhost /]# cd /opt
[root@localhost opt]# vim /opt/hnsw.txt

[root@localhost opt]# scp /opt/hnsw.txt 192.168.159.133:/home
root@192.168.159.133's password: 
hnsw.txt                                  100%   17     0.0KB/s   00:00

在服务器中查看传输文件内容:

使用客户端远程登录服务器,删除文件hnsw.txt,创建文件abc.txt

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/1682890.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

nssctf——web

[SWPUCTF 2021 新生赛]gift_F12 1.打开环境后&#xff0c;这里说要900多天会有flag&#xff0c;这是不可能的 2.f12查看源码&#xff0c;然后在html中查找flag &#xff08;在最上方的栏目中&#xff0c;或者按ctrlf&#xff09; [SWPUCTF 2021 新生赛]jicao 1.打开环境是一段…

【MySQL】MySQL的安装和基本概念

MySQL的安装和基本概念 一、环境安装1、环境及配置2、下载安装 二、基本概念1、主流数据库2、mysql和mysqld的区别和概念&#xff08;1&#xff09;概念1&#xff1a;了解CS结构&#xff08;2&#xff09;概念2&#xff1a;数据库指的是什么&#xff08;3&#xff09;概念3&…

模板中的右值引用(万能引用)、引用折叠与完美转发

模板中的右值引用&#xff08;万能引用&#xff09;、引用折叠与完美转发 文章目录 模板中的右值引用&#xff08;万能引用&#xff09;、引用折叠与完美转发一、万能引用与引用折叠1. 模板中的右值引用2. 自动类型推导(auto)与万能引用3. 引用折叠与万能引用4. lambda表达式捕…

巨某量引擎后台登录实战笔记 | Playwright自动化框架

前言 本文章中所有内容仅供学习交流&#xff0c;抓包内容、敏感网址、数据接口均已做脱敏处理&#xff0c;严禁用于商业用途和非法用途&#xff0c;否则由此产生的一切后果均与作者无关&#xff0c;若有侵权&#xff0c;请联系我立即删除&#xff01; 入正题看看滑块是怎么个事…

数字孪生项目开发流程

数字孪生&#xff08;Digital Twin&#xff09;项目的开发流程涉及多个步骤&#xff0c;从初始概念到最终部署和维护。以下是一个典型的数字孪生项目开发流程&#xff0c;通过这些步骤&#xff0c;开发团队可以有效地规划、设计、开发和维护数字孪生项目&#xff0c;确保其在实…

YOLOv5 Exception: Dataset not found.

在使用yolo v5训练时弹出了这个报错&#xff0c;就是没有找到数据集&#xff0c;dataset.yaml文件里面的train 和val 的路径配置不对&#xff0c;开始我是使用相对路径&#xff0c;后面修改成绝对路径就可以了

Ubuntu23.04开机时whoopsie-upload-all占用CPU 100%,风扇狂转

Ubuntu23.04开机时&#xff0c;风扇狂转散热&#xff0c;打开终端&#xff0c;输入top -c&#xff0c;查看占用cpu最高的进程&#xff0c;发现是python3在执行whoopsie-upload-all脚本文件。 什么是whoopsie&#xff1f; 这是“Ubuntu错误报告”守护程序&#xff0c;默认安装在…

DAB协议解读ETSI TS 103 461

一、说明 数字信号广播&#xff08; Digital Audio Broadcasting 简称DAB&#xff09;是继AM、FM传统模拟广播之后的第三代广播--数字信号广播&#xff0c;它提供了接近CD质量的声音&#xff0c;广播及商机无限的附加数据服务&#xff0c;具有抗噪声、抗干扰、抗电波传播衰落、…

采用LoRA方法微调llama3大语言模型

文章目录 前言一、Llama3模型简介1.下载llama3源码到linux服务器2.安装依赖3.测试预训练模型Meta-Llama-3-8B4.测试指令微调模型Meta-Llama3-8B-Instruct5.小结 二、LoRA微调Llama31.引入库2.编写配置文件3.LoRA训练的产物 三、测试新模型效果1.编写配置文件2.运行配置文件&…

(Qt) 默认QtWidget应用包含什么?

文章目录 ⭐前言⭐创建&#x1f6e0;️选择一个模板&#x1f6e0;️Location&#x1f6e0;️构建系统&#x1f6e0;️Details&#x1f6e0;️Translation&#x1f6e0;️构建套件(Kit)&#x1f6e0;️汇总 ⭐项目⚒️概要⚒️构建步骤⚒️清除步骤 ⭐Code&#x1f526;untitled…

Arcpy安装和环境配置

一、前言 ArcPy 是一个以成功的arcgisscripting 模块为基础并继承了arcgisscripting 功能进而构建而成的站点包。目的是为以实用高效的方式通过 Python 执行地理数据分析、数据转换、数据管理和地图自动化创建基础。该包提供了丰富纯正的 Python 体验&#xff0c;具有代码自动…

思维导图-VPN

浏览器集成了受信任的机构的证书

解决word里加入mathtype公式后行间距变大

1.布局>页面设置>文档网格&#xff0c;网格栏选为无网格 2.固定间距

数据库|基于T-SQL创建数据库

哈喽&#xff0c;你好啊&#xff0c;我是雷工&#xff01; SQL Server用于操作数据库的编程语言为Transaction-SQL,简称T-SQL。 本节学习基于T-SQL创建数据库。以下为学习笔记。 01 打开新建查询 首先连接上数据库&#xff0c;点击【新建查询】打开新建查询窗口&#xff0c; …

Linux基础命令[27]-gpasswd

文章目录 1. gpasswd 命令说明2. gpasswd 命令语法3. gpasswd 命令示例3.1 不加参数3.2 -a&#xff08;将用户加入组&#xff09;3.3 -d&#xff08;从组中删除用户&#xff09;3.4 -r&#xff08;删除组密码&#xff09;3.5 -M&#xff08;多个用户一起加入组&#xff09;3.6 …

23种设计模式(持续输出中)

一.设计模式的作用 设计模式是软件从业人员长期总结出来用于解决特定问题的通用性框架&#xff0c;它提高了代码的可维护性、可扩展性、可读性以及复用性。 二.设计模式 1.工厂模式 工厂模式提供了创建对象的接口&#xff0c;而无需制定创建对象的具体类&#xff0c;工厂类…

kafka集群跨区域跨集群同步方案MirrorMaker1 —— 筑梦之路

MirrorMaker原理架构 数据流向 上图也是一种比较常见的用法&#xff0c;这里作为记录。下面介绍一则实战案例。 网络架构 配置日志采集器filebeat 配置从哪里采集日志 输出到kafka集群 配置MirrorMaker消费者 参数说明&#xff1a; bootstrap.servers 指定消费哪个kafka的数…

【HarmonyOS4学习笔记】《HarmonyOS4+NEXT星河版入门到企业级实战教程》课程学习笔记(八)

课程地址&#xff1a; 黑马程序员HarmonyOS4NEXT星河版入门到企业级实战教程&#xff0c;一套精通鸿蒙应用开发 &#xff08;本篇笔记对应课程第 15 节&#xff09; P15《14.ArkUI组件-状态管理state装饰器》 回到最初的 Hello World 案例&#xff0c;首先验证 如果删掉 State…

Day22:Leetcode:654.最大二叉树 + 617.合并二叉树 + 700.二叉搜索树中的搜索 + 98.验证二叉搜索树

LeetCode&#xff1a;654.最大二叉树 1.思路 解决方案&#xff1a; 单调栈是本题的最优解&#xff0c;这里将单调栈题解本题的一个小视频放在这里 单调栈求解最大二叉树的过程当然这里还有leetcode大佬给的解释&#xff0c;大家可以参考一下&#xff1a; 思路很清晰&#xf…

软件开源协议与QT的开源协议介绍

一.常见的六种开源协议 1.BSD协议 BSD协议全称为“Berkely Software Distribution”&#xff0c;中文译为“伯克利软件发行版”。其最早用于伯克利UNIX操作系统上的开源贡献。 主要特点&#xff1a; 允许修改源码 允许源码再发布 允许商业软件发布和销售 约束&#xff1…