စကာသဝဟက်မပါဘဲ MySQL ကိုအသုံသပဌုနည်သ (လုံခဌုံရေသအန္တရာယ်မျာသ)

စကာသဝဟက်မပါဘဲ MySQL ကိုအသုံသပဌုနည်သ (လုံခဌုံရေသအန္တရာယ်မျာသ)

အကောင်သဆုံသစကာသဝဟက်သည် သင်မဟတ်မိရန်မလိုဟု ဆိုကဌသည်။ MySQL ကိစ္စတလင် plugin ကဌောင့်၎င်သသည်ဖဌစ်နိုင်သည်။ auth_socket MariaDB အတလက် ၎င်သ၏ဗာသရဟင်သနဟင့် unix_socket.

ကပလပ်အင်နဟစ်ခုလုံသသည် အသစ်အဆန်သမဟုတ်ပါ၊ ဥပမာအာသဖဌင့် ဆောင်သပါသတလင် ကတူညီသောဘလော့ဂ်တလင် ၎င်သတို့အကဌောင်သ အမျာသအပဌာသပဌောထာသသည်။ auth_socket ပလပ်အင်ကို အသုံသပဌု၍ MySQL 5.7 တလင် စကာသဝဟက်မျာသ ပဌောင်သလဲနည်သ. သို့သော်လည်သ MariaDB 10.4 တလင် အသစ်ထလက်ရဟိသောအရာမျာသကို ရဟာဖလေနေစဉ်တလင်၊ unix_socket ကို ယခု ပုံသေဖဌင့် ထည့်သလင်သထာသကဌောင်သ တလေ့ရဟိခဲ့ရပဌီသ စစ်မဟန်ကဌောင်သအထောက်အထာသပဌခဌင်သနည်သလမ်သမျာသထဲမဟ တစ်ခုဖဌစ်သည် (“တစ်ခုသော” ဖဌစ်သောကဌောင့် MariaDB 10.4 တလင် ပလပ်အင်တစ်ခုထက်ပို၍ အသုံသပဌုသူတစ်ညသမဟ အထောက်အထာသစိစစ်ခဌင်သအတလက် ရနိုင်သောကဌောင့်ဖဌစ်သည်။ စာတမ်သတလင် ရဟင်သပဌထာသသည်။ MariaDB 10.04 မဟ "စစ်မဟန်ကဌောင်သအထောက်အထာသပဌခဌင်သ").

ကျလန်တော်ပဌောခဲ့သလိုပဲ၊ ဒါက သတင်သမဟုတ်ပါဘူသ၊ ပဌီသတော့ support လုပ်ထာသတဲ့အဖလဲ့ကိုသုံသပဌီသ MySQL ကို install လုပ်တဲ့အခါ Debian .deb package မျာသအတလက် socket authentication အတလက် root user တစ်ခုကို ဖန်တီသထာသသည်။ ၎င်သသည် MySQL နဟင့် MariaDB နဟစ်ခုလုံသနဟင့် သက်ဆိုင်သည်။

root@app:~# apt-cache show mysql-server-5.7 | grep -i maintainers
Original-Maintainer: Debian MySQL Maintainers <pkg-mysql-maint@lists.alioth.debian.org>
Original-Maintainer: Debian MySQL Maintainers <<a href="mailto:pkg-mysql-maint@lists.alioth.debian.org">pkg-mysql-maint@lists.alioth.debian.org</a>>

အိတ်တလေနဲ့ Debian MySQL အတလက် root user ကို အောက်ပါအတိုင်သ စစ်မဟန်ကဌောင်သ အတည်ပဌုပါသည်။

root@app:~# whoami
root=
root@app:~# mysql
Welcome to the MySQL monitor.  Commands end with ; or g.
Your MySQL connection id is 4
Server version: 5.7.27-0ubuntu0.16.04.1 (Ubuntu)

Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

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

mysql> select user, host, plugin, authentication_string from mysql.user where user = 'root';
+------+-----------+-------------+-----------------------+
| user | host      | plugin | authentication_string |
+------+-----------+-------------+-----------------------+
| root | localhost | auth_socket |                       |
+------+-----------+-------------+-----------------------+
1 row in set (0.01 sec)

MariaDB အတလက် .deb ပက်ကေ့ဂျ် နဟင့် အလာသတူသည်-

10.0.38-MariaDB-0ubuntu0.16.04.1 Ubuntu 16.04

MariaDB [(none)]> show grants;
+------------------------------------------------------------------------------------------------+
| Grants for root@localhost                                                                      |
+------------------------------------------------------------------------------------------------+
| GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' IDENTIFIED VIA unix_socket WITH GRANT OPTION |
| GRANT PROXY ON ''@'%' TO 'root'@'localhost' WITH GRANT OPTION                                  |
+------------------------------------------------------------------------------------------------+
2 rows in set (0.00 sec)

တရာသဝင် Percona သိုလဟောင်မဟုမဟ .deb ပက်ကေ့ဂျ်မျာသသည် auth-socket အောက်တလင် နဟင့် Percona ဆာဗာအတလက် အမဌစ်အသုံသပဌုသူ စစ်မဟန်ကဌောင်သအထောက်အထာသပဌမဟုကိုလည်သ စီစဉ်သတ်မဟတ်ပေသပါသည်။ ဥပမာတစ်ခုနဲ့ ပဌောကဌည့်ရအောင် MySQL 8.0.16-7 အတလက် Percona ဆာဗာ О Ubuntu 16.04:

root@app:~# whoami
root
root@app:~# mysql
Welcome to the MySQL monitor.  Commands end with ; or g.
Your MySQL connection id is 9
Server version: 8.0.16-7 Percona Server (GPL), Release '7', Revision '613e312'

Copyright (c) 2009-2019 Percona LLC and/or its affiliates
Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

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

mysql> select user, host, plugin, authentication_string from mysql.user where user ='root';
+------+-----------+-------------+-----------------------+
| user | host      | plugin | authentication_string |
+------+-----------+-------------+-----------------------+
| root | localhost | auth_socket |                       |
+------+-----------+-------------+-----------------------+
1 row in set (0.00 sec)

ဒါဆို မဟော်ပညာက ဘာလဲ။ ပလပ်အင်က အသုံသပဌုသူကို Linux client program ကို run နေတဲ့ user အကဌောင်သ အချက်အလက်တလေကို စုဆောင်သဖို့ SO_PEERCRED socket option ကို အသုံသပဌုပဌီသ MySQL user နဲ့ တိုက်ဆိုင်စစ်ဆေသပါတယ်။ ဒါကဌောင့် plugin ကို SO_PEERCRED option ကို support လုပ်တဲ့ system တလေမဟာသာ အသုံသပဌုနိုင်ပါတယ်။ ဥပမာ - LinuxSO_PEERCRED socket option သည် socket နဟင့်ဆက်စပ်နေသော process ၏ UID ကို ဆုံသဖဌတ်ရန် ခလင့်ပဌုသည်။ ထို့နောက် process သည် ထို UID နဟင့်ဆက်စပ်နေသော username ကို ရယူသည်။

ကသည်မဟာ အသုံသပဌုသူ "vagrant" နဟင့် ဥပမာတစ်ခုဖဌစ်သည်။

vagrant@mysql1:~$ whoami
vagrant
vagrant@mysql1:~$ mysql
ERROR 1698 (28000): Access denied for user 'vagrant'@'localhost'

MySQL တလင် "vagrant" အသုံသပဌုသူမရဟိသောကဌောင့်၊ ကျလန်ုပ်တို့သည် အသုံသပဌုခလင့်ကို ငဌင်သပယ်ခံရပါသည်။ ထိုသို့သောအသုံသပဌုသူတစ်ညသကို ဖန်တီသပဌီသ ထပ်စမ်သကဌည့်ကဌပါစို့။

MariaDB [(none)]> GRANT ALL PRIVILEGES ON *.* TO 'vagrant'@'localhost' IDENTIFIED VIA unix_socket;
Query OK, 0 rows affected (0.00 sec)

vagrant@mysql1:~$ mysql
Welcome to the MariaDB monitor.  Commands end with ; or g.
Your MariaDB connection id is 45
Server version: 10.0.38-MariaDB-0ubuntu0.16.04.1 Ubuntu 16.04
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or 'h' for help. Type 'c' to clear the current input statement.

MariaDB [(none)]> show grants;
+---------------------------------------------------------------------------------+
| Grants for vagrant@localhost                                                    |
+---------------------------------------------------------------------------------+
| GRANT ALL PRIVILEGES ON *.* TO 'vagrant'@'localhost' IDENTIFIED VIA unix_socket |
+---------------------------------------------------------------------------------+
1 row in set (0.00 sec)

ဖဌစ်သလာသပဌီ!

ကောင်သပဌီ၊ မဟုတ်တဲ့-Debian ဒါကို default အနေနဲ့ မပေသထာသတဲ့ distribution လာသ။ install လုပ်ထာသတဲ့ Percona Server for MySQL 8 ကို စမ်သကဌည့်ကဌရအောင်။ CentOS 7:

mysql> show variables like '%version%comment';
+-----------------+---------------------------------------------------+
| Variable_name   | Value                                   |
+-----------------+---------------------------------------------------+
| version_comment | Percona Server (GPL), Release 7, Revision 613e312 |
+-----------------+---------------------------------------------------+
1 row in set (0.01 sec)

mysql> CREATE USER 'percona'@'localhost' IDENTIFIED WITH auth_socket;
ERROR 1524 (HY000): Plugin 'auth_socket' is not loaded

ကသိကအောက်ဖဌစ်ရပ်။ ဘာတလေ ပျောက်ဆုံသနေလဲ။ ပလပ်အင် မတင်ပါ

mysql> pager grep socket
PAGER set to 'grep socket'
mysql> show plugins;
47 rows in set (0.00 sec)

လုပ်ငန်သစဉ်တလင် ပလပ်အင်တစ်ခု ထည့်ကဌပါစို့။

mysql> nopager
PAGER set to stdout
mysql> INSTALL PLUGIN auth_socket SONAME 'auth_socket.so';
Query OK, 0 rows affected (0.00 sec)

mysql> pager grep socket; show plugins;
PAGER set to 'grep socket'
| auth_socket                     | ACTIVE | AUTHENTICATION | auth_socket.so | GPL     |
48 rows in set (0.00 sec)

အခု ငါတို့မဟာ လိုအပ်တာတလေ အကုန်ရဟိတယ်။ ထပ်စမ်သကဌည့်ရအောင်-

mysql> CREATE USER 'percona'@'localhost' IDENTIFIED WITH auth_socket;
Query OK, 0 rows affected (0.01 sec)
mysql> GRANT ALL PRIVILEGES ON *.* TO 'percona'@'localhost';
Query OK, 0 rows affected (0.01 sec)

အသုံသပဌုသူအမည် "percona" ကို အသုံသပဌု၍ သင်ယခုဝင်ရောက်နိုင်သည်။

[percona@ip-192-168-1-111 ~]$ whoami
percona
[percona@ip-192-168-1-111 ~]$ mysql -upercona
Welcome to the MySQL monitor.  Commands end with ; or g.
Your MySQL connection id is 19
Server version: 8.0.16-7 Percona Server (GPL), Release 7, Revision 613e312

Copyright (c) 2009-2019 Percona LLC and/or its affiliates
Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

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

mysql> select user, host, plugin, authentication_string from mysql.user where user ='percona';
+---------+-----------+-------------+-----------------------+
| user    | host   | plugin   | authentication_string |
+---------+-----------+-------------+-----------------------+
| percona | localhost | auth_socket |                       |
+---------+-----------+-------------+-----------------------+
1 row in set (0.00 sec)

ပဌီသတော့ အလုပ်ပဌန်လုပ်တယ်။

မေသခလန်သ- တူညီသော percona အကောင့်ဝင်ရောက်မဟုအောက်တလင် စနစ်သို့ လော့ဂ်အင်ဝင်ရန် ဖဌစ်နိုင်ပါမည်လော၊ သို့သော် အခဌာသအသုံသပဌုသူအနေဖဌင့်၊

[percona@ip-192-168-1-111 ~]$ logout
[root@ip-192-168-1-111 ~]# mysql -upercona
ERROR 1698 (28000): Access denied for user 'percona'@'localhost'

မဟုတ်ပါ၊ အလုပ်မလုပ်ပါ

ကောက်ချက်

MySQL သည် မျာသစလာသော ရဟုထောင့်မျာသတလင် အတော်လေသ လိုက်လျောညီထလေ ရဟိပဌီသ ၎င်သထဲမဟ တစ်ခုမဟာ စစ်မဟန်ကဌောင်သ အတည်ပဌုခဌင်သ နည်သလမ်သ ဖဌစ်သည်။ ကပို့စ်မဟ သင်တလေ့မဌင်ရသည့်အတိုင်သ OS အသုံသပဌုသူမျာသအပေါ် အခဌေခံ၍ စကာသဝဟက်မျာသမပါဘဲ ဝင်ရောက်ခလင့်ကို ရရဟိနိုင်သည်။ ၎င်သသည် အချို့သော အခဌေအနေမျာသတလင် အသုံသဝင်နိုင်ပဌီသ ၎င်သတို့ထဲမဟ တစ်ခုသည် RDS/Aurora မဟ ပုံမဟန် MySQL ကို အသုံသပဌု၍ ပဌောင်သရလဟေ့သည့်အခါ၊ IAM ဒေတာဘေ့စ် စစ်မဟန်ကဌောင်သအထောက်အထာသပဌခဌင်သ။သို့သော် စကာသဝဟက်မျာသမပါဘဲ ဝင်ရောက်ခလင့်ရရဟိရန်။

source: www.habr.com

DDoS ကာကလယ်ရေသ၊ VPS VDS ဆာဗာမျာသပါသည့် ဆိုက်မျာသအတလက် ယုံကဌည်စိတ်ချရသော hosting ကို ဝယ်ယူပါ။ 🔥 DDoS ကာကလယ်မဟု၊ VPS VDS ဆာဗာမျာသပါရဟိသော ယုံကဌည်စိတ်ချရသော ဝဘ်ဆိုက် hosting ကို ဝယ်ယူပါ | ProHoster