configure jump server to use SSL for MySQL server 5.7 version

How to configure ezeelogin  to use SSL for MySQL database connections  on ubuntu 16.04 ?

Mysql - SSL setup on Ubuntu  mysql server 5.7 version

1. Check the Current SSL/TLS Status

   Log into a MySQL session 

root@gateway:~# mysql -u root -p -h 127.0.0.1

  Show the state of the SSL/TLS variables by typing:

mysql> SHOW VARIABLES LIKE ’%ssl%’;

Output
+---------------+----------+
| Variable_name | Value    |
+---------------+----------+
| have_openssl  | DISABLED |
| have_ssl      | DISABLED |
| ssl_ca        |          |
| ssl_capath    |          |
| ssl_cert      |          |
| ssl_cipher    |          |
| ssl_crl       |          |
| ssl_crlpath   |          |
| ssl_key       |          |
+---------------+----------+
9 rows in set (0.01 sec)

 

  The have_openssl and have_ssl variables are both marked as DISABLED. This means that SSL functionality has been compiled into the server, but that it is not yet enabled.

 

2. Generate SSL/TLS Certificates and Keys

To enable SSL connections to MySQL, we first need to generate the appropriate certificate and key files

 we can use the following command to generate the necessary files.

 The files will be created in MySQL’s data directory, located at  /var/lib/mysql

root@gateway:~# mysql_ssl_rsa_setup --uid=mysql

Check the generated files by typing:

root@gateway:~# find /var/lib/mysql -name ’*.pem’ -ls

output

256740 4 -rw-r--r-- 1 mysql mysql 1078 Mar 17 17:24 /var/lib/mysql/server-cert.pem
256735 4 -rw------- 1 mysql mysql 1675 Mar 17 17:24 /var/lib/mysqlsql/ca-key.pem<^>
256739 4 -rw-r--r-- 1 mysql mysql 451 Mar 17 17:24 /var/lib/mysqlsql/public_key.pem<^>
256741 4 -rw------- 1 mysql mysql 1679 Mar 17 17:24 /var/lib/mysqlsql/client-key.pem<^>
256737 4 -rw-r--r-- 1 mysql mysql 1074 Mar 17 17:24 /var/lib/mysqlsql/ca.pem<^>
256743 4 -rw-r--r-- 1 mysql mysql 1078 Mar 17 17:24 /var/lib/mysqlsql/client-cert.pem<^>
256736 4 -rw------- 1 mysql mysql 1675 Mar 17 17:24 /var/lib/mysqlsql/private_key.pem<^>
256738 4 -rw------- 1 mysql mysql 1675 Mar 17 17:24 /var/lib/mysqlsql/server-key.pem<^>

 

Enable SSL Connections on the MySQL Server

Restart the MySQL service

root@gateway:~# systemctl restart mysql

After restarting, open up a new MySQL session using the same command as before.

root@gateway:~# mysql -u root -p -h 127.0.0.1

Check state of the SSL/TLS variables by typing:

mysql> SHOW VARIABLES LIKE ’%ssl%’;

Output
+---------------+----------------+
| Variable_name | Value          |
+---------------+----------------+
| have_openssl  | YES            |
| have_ssl      | YES            |
| ssl_ca        | Ca.pem         |
| ssl_capath    |                |
| ssl_cert      | server-cert.pem|
| ssl_cipher    |                |
| ssl_crl       |                |
| ssl_crlpath   |                |
| ssl_key       | server-key.pem |
+---------------+----------------+
9 rows in set (0.01 sec)

 

The have_openssl and have_ssl variables read "YES" instead of "DISABLED" this time.

 

Check the connection details by the following command:

 

 

root@gateway:~# mysql -u ezlogin_database_username -p -h hostname or ip --ssl-ca=/var/lib/mysql/ca.pem --ssl-cert=/var/lib/mysql/client-cert.pem --ssl-key=/var/lib/mysql/client-key.pem 


example :

 

 

root@gateway:~# mysql -u ezlogin_xxxx -p -h 10.11.1.11 --ssl-ca=/var/lib/mysql/ca.pem --ssl-cert=/var/lib/mysql/client-cert.pem --ssl-key=/var/lib/mysql/client-key.pem 

 

 

mysql> \s

--------------- 

. . .

SSL: Cipher in use is DHE-RSA-AES256-SHA

. . .

Connection: 127.0.0.1 via TCP/IP

. . .

---------------- 

 

SSL cipher is displayed, indicating that SSL is being used to secure our connection.

 

3. Configure ezeelogin jump server to use SSL for Mysql

 

Add mysql_ssl_key,mysql_ssl_cert,mysql_ssl_ca to /usr/local/etc/ezlogin/ez.conf

Edit the  /usr/local/etc/ezlogin/ez.conf file add the following

root@gateway:~# vi /usr/local/etc/ezlogin/ez.conf

#Add the following 

system_folder /var/www/ezlogin/
force_https no
uri_path /ezlogin/
db_host 10.10.1.11
db_port 3306
db_name ezlogin_qzms
db_user ezlogin_edcjwz
db_pass dsH)$s5xAE[QgFms
db_prefix aqvo_
cookie_encryption_key ASvs8^pnu^^X9
cookie_name lcrrfs
cookie_path /ezlogin/
www_folder /var/www/html/ezlogin/
admin_user admin
mysql_encrypt yes
mysql_ssl_key /var/lib/mysql/client-key.pem
mysql_ssl_cert /var/lib/mysql/client-cert.pem
mysql_ssl_ca /var/lib/mysql/ca.pem
mysql_ssl_capath /var/lib/mysql
mysql_ssl_cipher ALL:!ADH
mysql_ssl_verify no

 

Make sure that you have changed db_port to 3306 & db_host to IP Address of your host

 4. Change the bind-address & allow the ezeelogin jump server user to access the database.

   

 Edit the  /etc/mysql/mysql.conf.d/mysqld.cnf & change bind-address 

root@gateway:~# vi /etc/mysql/mysql.conf.d/mysqld.cnf

 

Change bind-address to host ip(server ip)

bind-address x.x.x.x (Host ip)

 

  Restart the MySQL service

root@gateway:~# systemctl restart mysql

 

  you can find out ezeelogin jump server dbname and  mysql username from the ez.conf file

root@gateway:~# cat /usr/local/etc/ezlogin/ez.conf


system_folder /var/www/ezlogin/
force_https no
uri_path /ezlogin/
db_host 10.10.1.11
db_port 3306
db_name ezlogin_qzms
db_user ezlogin_edcjwz
db_pass dsH)$s5xAE[QgFms
db_prefix aqvo_
cookie_encryption_key ASvs8^pnu^^X9
cookie_name lcrrfs
cookie_path /ezlogin/
www_folder /var/www/html/ezlogin/
admin_user admin
mysql_encrypt yes
mysql_ssl_key /var/lib/mysql/client-key.pem
mysql_ssl_cert /var/lib/mysql/client-cert.pem
mysql_ssl_ca /var/lib/mysql/ca.pem
mysql_ssl_capath /var/lib/mysql
mysql_ssl_cipher ALL:!ADH
mysql_ssl_verify no

 

Use this command for granting privileges for root " GRANT USAGE ON ezlogin_databasename.* TO 'root'@'Hostname or ip' WITH GRANT OPTION;

Login to mysql 

root@gateway:~# mysql -u root -p 

[Enter password]

mysql> grant all on ezlogin_databasename.* to 'mysql_username'@'%' identified by 'password';

example : mysql > grant all on ezlogin_xxx.* to 'ezlogin_xxxx'@'%' identified by 'dsH)$s5xAE[QgFmfsfgg';

mysql > flush privileges;

mysql > exit 

 

 Check if you can login to mysql using ezeelogin jump server databases

root@gateway:~# mysql -u ezeelogin_database_username -h 10.11.1.11 -p

Enter Password:

mysql >

mysql > exit

 

If you have any difficulties please contact support 

5 (1)
Article Rating (1 Votes)
Rate this article
    Attached Files
    There are no attachments for this article.
    Related Articles RSS Feed
    setup web ssh console in ezeelogin and ssh via browser
    Viewed 7378 times since Tue, Jan 30, 2018
    How to find a server by its hostname, ip address, very quickly in ezsh shell
    Viewed 1405 times since Tue, Mar 27, 2018
    How to bypass the group menu in the backend shell and go directly to the entire server listing?
    Viewed 1942 times since Tue, Mar 27, 2018
    How can i disable MySQL strict mode ?
    Viewed 1766 times since Tue, Feb 12, 2019
    Configure Nginx webserver on Jump server / Bastion host
    Viewed 6666 times since Fri, Nov 3, 2017
    How to configure Yubikey two factor authentication in ssh ?
    Viewed 4993 times since Thu, Jun 15, 2017
    How to install free SSL with Let’s Encrypt?
    Viewed 1568 times since Wed, Jul 18, 2018
    How to add ssh public key for passwordless authentication in ssh
    Viewed 2407 times since Fri, Sep 1, 2017
    Setting session time out for the webinterface
    Viewed 2800 times since Wed, Jun 14, 2017
    How to reset cluster keys in ezeelogin Master-slave Configuration ?
    Viewed 791 times since Fri, Jun 8, 2018