Usage scenarios:
1, the MySQL database administrator account only allows local login
2. Application Connection account only allows the program to deploy the server to which the IP address is connected
Implementation method:
The client tool connects to the MySQL database server with a password-free SSH key pair, and then logs on locally from the server via the database's corresponding account.
1. Installing the SSH-related package
yum-y Install openssh-clients # ssh-copy-id Command
2. using Ssh-keygen on the local machine to generate a public-key private key pair
[[Email protected]~]$ Ssh-keygen
3. Copy the public key to the remote machine with Ssh-copy-id
-I: Specifying a public key file
#pgmaster1
[Root @cos68srv ~]$ ssh-copy-id-i ~/.ssh/id_rsa.pub [email protected]
4. to save the root user's private key download locally
Easy to manage named by IP address classification and placed in the Rsa_keys directory of the Navicat tool
650) this.width=650; "Src=" https://s4.51cto.com/wyfs02/M00/95/30/wKiom1kSq3CRQaPAAAA1OLqnv58368.png-wh_500x0-wm_ 3-wmp_4-s_2303830161.png "title=" 1.png "alt=" Wkiom1ksq3crqapaaaa1olqnv58368.png-wh_50 "/>
5. Log on to remote machine does not enter password
Database has administrator account sysadmin, but only on local server login
650) this.width=650; "Src=" https://s3.51cto.com/wyfs02/M00/95/30/wKiom1kSq4uSqQOzAAAiJ4SAtMw091.png-wh_500x0-wm_ 3-wmp_4-s_3004714744.png "title=" 2.png "alt=" Wkiom1ksq4usqqozaaaij4satmw091.png-wh_50 "/>
Open the Navicat tool to connect to the remote MySQL service
650) this.width=650; "Src=" https://s4.51cto.com/wyfs02/M01/95/30/wKiom1kSq5_xpSx9AABxJmUtyvA977.png-wh_500x0-wm_ 3-wmp_4-s_367280898.png "title=" 3.png "alt=" Wkiom1ksq5_xpsx9aabxjmutyva977.png-wh_50 "/>
On the General page, fill in the configuration for the normal connection to the MySQL service, only the address using localhost/127.0.0.1
650) this.width=650; "Src=" https://s2.51cto.com/wyfs02/M02/95/30/wKioL1kSq8jyJYm1AAB6XyOMvu8725.png-wh_500x0-wm_ 3-wmp_4-s_2826501506.png "title=" 4.png "alt=" Wkiol1ksq8jyjym1aab6xyomvu8725.png-wh_50 "/>
In the "SSH" page to fill in the MySQL database server address, the system login account (for system security can also use other users with login rights), authentication method Select "Public key", in the "Private key" Select the above download saved private key file, password phrase to fill, select "Save Passphrase" can be.
650) this.width=650; "Src=" https://s3.51cto.com/wyfs02/M01/95/30/wKioL1kSq9_C-eSAAACNkKFn5lI470.png-wh_500x0-wm_ 3-wmp_4-s_279233256.png "title=" 5.png "alt=" Wkiol1ksq9_c-esaaacnkkfn5li470.png-wh_50 "/>
The test was successful.
This article is from the "Lone Nine Swords" blog, please be sure to keep this source http://130030.blog.51cto.com/120030/1924090
Windows platform uses navicat for MySQL to connect to the remote MySQL database via SSH key authentication