網絡安全技術與應用:遠程控制與數據庫安全

實驗準備

軟件: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.pswp.cn/diannao/14351.shtml
繁體地址,請注明出處:http://hk.pswp.cn/diannao/14351.shtml
英文地址,請注明出處:http://en.pswp.cn/diannao/14351.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

【C++刷題】優選算法——遞歸第二輯

全排列 vector<vector<int>> vv; void dfs(vector<int>& nums, vector<int>& v, vector<bool>& check) {if(v.size() nums.size()){vv.push_back(v);return;}for(int i 0; i < nums.size(); i){if(check[i] false){v.push_ba…

pillow學習5

ImageEnhance 模塊 內置的 ImageEnhance 模塊中包含了多個用于增強圖像效果的函數&#xff0c;主要用來調整圖像 的色彩、對比度、亮度和清晰度等&#xff0c;感覺上和調整電視機的顯示參數一樣。 在模塊 ImageEnhance 中&#xff0c;所有的圖片增強對象都實現一個通用的接口。…

nginx的配置以及常見命令

Nginx配置與常用命令指南 Nginx是一個高性能的HTTP和反向代理服務器&#xff0c;也是一個IMAP/POP3/SMTP服務器。由于它的穩定性、豐富的功能集、簡單的配置文件和低資源消耗&#xff0c;Nginx在全球范圍內被廣泛使用。在本文中&#xff0c;我們將介紹Nginx的基本配置和一些常…

車載網絡測試實操源碼_使用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…

WPF 的 style 定義 使用 繼承 復用

style 樣式 如何定義一個 style 樣式 <Button Content"樣式" Width"100" Height"50"><Button.Style><Style></Style></Button.Style></Button>擁有的屬性 targetType “” 針對什么類型生效setter 設置屬…

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…

18.網絡編程

網絡編程 又稱為Socket編程。 Java中網絡編程主要是以Java語言完成信息數據在網絡上的傳輸。 網絡 計算機網絡&#xff0c;指的是將不同地理位置的多臺計算機連接起來&#xff0c;可以實現信息共享和信息傳輸。 Java是Internet上的語言&#xff0c;提供了對網絡應用程序的…

筆記 | 《css權威指南》

網絡安全色 URL text-indent line-height & vertical-align 字體 font-weight 400 normal 700 bold background-attachment

SpringBoot項目集成JetCache緩存框架步驟

JetCache是阿里開源的基于java開發的緩存框架&#xff0c;支持多種緩存類型&#xff1a;本地緩存、分布式緩存、多級緩存。能夠滿足不同業務場景的緩存需求。 1.導入依賴 <!--jetcache緩存 --> <dependency><groupId>com.alicp.jetcache</groupId>&l…

【調試筆記-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 的出現解決了眾多企業…

Python庫之lxml的簡介、安裝、使用方法詳細攻略

Python庫之lxml的簡介、安裝、使用方法詳細攻略 簡介 lxml是一個用于處理XML和HTML文檔的Python庫&#xff0c;它提供了簡單易用的API來解析和生成這些文檔。lxml以其性能和易用性而受到廣泛歡迎&#xff0c;特別適合于需要處理大量數據或需要高性能解析的場景。 安裝 安裝…

運行時異常和編譯時異常的區別

Java中的異常被分為兩大類&#xff1a;編譯時異常和運行時異常。 都是RuntimeException類及其子類異常&#xff0c;如NullPointerException、IndexOutOfBoundsException。這些異常是不檢查異常&#xff0c;運行時異常的特點是Java編譯器不會檢查它&#xff0c;程序中可以選擇捕…

純代碼如何實現WordPress搜索包含評論內容?

WordPress自帶的搜索默認情況下是不包含評論內容的&#xff0c;不過有些WordPress網站評論內容比較多&#xff0c;而且也比較有用&#xff0c;所以想要讓用戶在搜索時也能夠同時搜索到評論內容&#xff0c;那么應該怎么做呢&#xff1f; 網絡上很多教程都是推薦安裝SearchWP插…