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

实验准备

软件: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 MariaDBSERVERS 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 ServerCopyright (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 ServerCopyright (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 -ADatabase 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 ServerCopyright (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 ServerCopyright (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 1500inet 192.168.159.134  netmask 255.255.255.0  broadcast 192.168.159.255inet6 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 0TX packets 275  bytes 26173 (25.5 KiB)TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536inet 127.0.0.1  netmask 255.0.0.0inet6 ::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 0TX 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 1500inet 192.168.159.133  netmask 255.255.255.0  broadcast 192.168.159.255inet6 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 0TX packets 297  bytes 30414 (29.7 KiB)TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536inet 127.0.0.1  netmask 255.0.0.0inet6 ::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 0TX 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.mzph.cn/diannao/14351.shtml

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

相关文章

车载网络测试实操源码_使用CAPL脚本模拟发送符合协议要求(Counter和CRC)的CAN报文

系列文章目录 车载网络测试实操源码_使用CAPL脚本解析hex、S19、vbf文件 车载网络测试实操源码_使用CAPL脚本对CAN报文的Counter和CRC进行实时监控 车载网络测试实操源码_使用CAPL脚本模拟发送符合协议要求(Counter和CRC)的CAN报文 车载网络测试实操源码_使用CAPL脚本实现安全…

利用神经网络学习语言(四)——深度循环神经网络

相关说明 这篇文章的大部分内容参考自我的新书《解构大语言模型&#xff1a;从线性回归到通用人工智能》&#xff0c;欢迎有兴趣的读者多多支持。 本文涉及到的代码链接如下&#xff1a;regression2chatgpt/ch10_rnn/char_rnn_batch.ipynb 《循环神经网络&#xff08;RNN&…

【移花接木】OpenCV4.8 For Java 深度学习 实时人脸检测

学习《OpenCV应用开发&#xff1a;入门、进阶与工程化实践》一书&#xff0c;学会本文所有技能就这么简单&#xff01; 做真正的OpenCV开发者&#xff0c;从入门到入职&#xff0c;一步到位&#xff01; 前言 我写这篇文章之前&#xff0c;我搜索整个网络文章跟问各种语言大模…

速卖通测评揭秘:如何选择安全的渠道操作

许多商家对测评存在误解&#xff0c;认为只需进行几次测评就能迅速打造爆款。实际上&#xff0c;测评是一个需要计划和持久性的过程&#xff0c;以便让平台检测到产品的受众程度并提高产品的曝光和权重。 在进行测评时&#xff0c;安全是首要考虑的问题。平台可以通过设备、网…

黑马点评1——短信篇(基于session)

&#x1f308;hello&#xff0c;你好鸭&#xff0c;我是Ethan&#xff0c;一名不断学习的码农&#xff0c;很高兴你能来阅读。 ✔️目前博客主要更新Java系列、项目案例、计算机必学四件套等。 &#x1f3c3;人生之义&#xff0c;在于追求&#xff0c;不在成败&#xff0c;勤通…

如何使用多种算法解决LeetCode第135题——分发糖果问题

❤️❤️❤️ 欢迎来到我的博客。希望您能在这里找到既有价值又有趣的内容&#xff0c;和我一起探索、学习和成长。欢迎评论区畅所欲言、享受知识的乐趣&#xff01; 推荐&#xff1a;数据分析螺丝钉的首页 格物致知 终身学习 期待您的关注 导航&#xff1a; LeetCode解锁100…

Ubuntu中 petalinux 安装 移植linux --tftp/tftp-hpa服务的方法

Xilinx 文档 PetaLinux 指南&#xff1a;如何创建 PetaLinux 环境 &#xff08;2019.1&#xff09; PetaLinux工具参考指南 PetaLinux安装详解(Xilinx , linux, zynq, zynqMP) petalinux 2020.1安装教程 一、PetaLinux工具和库安装 PetaLinux 工具要求主机系统 /bin/sh 为“b…

笔记 | 《css权威指南》

网络安全色 URL text-indent line-height & vertical-align 字体 font-weight 400 normal 700 bold background-attachment

【调试笔记-20240516-Windows-使用VS2019编译edk2(上)】

调试笔记-系列文章目录 调试笔记-20240516-Windows-使用VS2019编译edk2&#xff08;上&#xff09; 文章目录 调试笔记-系列文章目录调试笔记-20240516-Windows-使用VS2019编译edk2&#xff08;上&#xff09; 前言一、安装开发工具1. 安装 VS20192. 安装 Python 3.103. 安装 …

pdf加水印怎么加?3种添加水印方法分享

pdf加水印怎么加&#xff1f;PDF加水印不仅是为了保护文档内容&#xff0c;确保信息的安全性和完整性&#xff0c;更是一种有效的版权保护措施。通过添加水印&#xff0c;您可以在文档中嵌入公司名称、日期、编号等信息&#xff0c;以明确文档的归属权和使用限制。此外&#xf…

小而美:两步完成从源码到应用的极简交付

作者&#xff1a;花三&#xff08;王俊&#xff09; Serverless 应用引擎 SAE 是阿里云推出的一款零代码改造、极简易用、自适应弹性的容器化应用托管平台&#xff0c;面市以来为几万家企业客户提供服务&#xff0c;运行稳定&#xff0c;广受好评。 SAE 的出现解决了众多企业…

运行时异常和编译时异常的区别

Java中的异常被分为两大类&#xff1a;编译时异常和运行时异常。 都是RuntimeException类及其子类异常&#xff0c;如NullPointerException、IndexOutOfBoundsException。这些异常是不检查异常&#xff0c;运行时异常的特点是Java编译器不会检查它&#xff0c;程序中可以选择捕…

纯代码如何实现WordPress搜索包含评论内容?

WordPress自带的搜索默认情况下是不包含评论内容的&#xff0c;不过有些WordPress网站评论内容比较多&#xff0c;而且也比较有用&#xff0c;所以想要让用户在搜索时也能够同时搜索到评论内容&#xff0c;那么应该怎么做呢&#xff1f; 网络上很多教程都是推荐安装SearchWP插…

Spring Web MVC介绍及详细教程

目录 1.什么是Spring Web MVC&#xff1f; 1.1 MVC定义 1.2 Spring MVC与MVC关系 2.为什么要学习Spring MVC 3.项目创建 4.Spring MVC连接 4.1 RequestMapping 4.2 PostMapping和GetMapping 5.Spring MVC参数获取 5.1 获取单个参数 5.2 获取多个参数 5.3 获取普通对…

通用代码生成器应用场景一,项目前期

通用代码生成器是一种自动化编程软件&#xff0c;是一种先进的编译系统。它具有表级抽象。把系统抽象为域对象&#xff0c;枚举&#xff0c;弹性登录模块&#xff0c;复杂版面和图形报表。使用通用代码生成器完成项目前期&#xff0c;比直接使用对应的高级语言快的多&#xff0…

element Notification 消息过多需要折叠

Notification 消息过多太长 希望能折叠 如图下效果 element-plus 可以将dom 插入到具体的元素 结合css :nth-child 来控制样式达到效果 element dom 只能插入到body中 所以无法使用:nth-child 1.Notification需要消息提示时设置class let eleNum 0 // 弹窗的序号 function…

vue+canvas实现逐字手写效果

在pc端进行逐字手写的功能。用户可以在一个 inputCanvas 上书写单个字&#xff0c;然后在特定时间后将这个字添加到 outputCanvas 上&#xff0c;形成一个逐字的手写效果。用户还可以保存整幅图像或者撤销上一个添加的字。 <template><div class"container"…

小红书-社区搜索部 (NLP、CV算法实习生) 一面面经

&#x1f604; 整个流程按如下问题展开&#xff0c;用时60min左右面试官人挺好&#xff0c;前半部分问问题&#xff0c;后半部分coding一道题。 各位有什么问题可以直接评论区留言&#xff0c;24小时内必回信息&#xff0c;放心~ 文章目录 1、自我介绍2、介绍下项目&#xff…

淄博公司商标驳回复审条件及流程

商标是人工审查的&#xff0c;所以不同的人会有不同的想法和意见&#xff0c;导致同一案件的审查结果不同。特别是商标审查周期缩短到5个月&#xff0c;全国平均每个工作日有1万多个商标提交申请&#xff0c;而全国只有一个商标审查单位——国家商标局提交申请。这种情况下&…

Java版工程行业管理系统-提升工程项目的综合管理能力

工程项目管理涉及众多环节和角色&#xff0c;如何实现高效协同和信息共享是关键。本文将介绍一个采用先进技术框架的Java版工程项目管理系统&#xff0c;该系统支持前后端分离&#xff0c;功能全面&#xff0c;可满足不同角色的需求。从项目进度图表到施工地图&#xff0c;再到…