As a high-speed database, redis must have a corresponding security mechanism on the Internet for protection.
1. The safer method is to bind an IP address for control.
Copy codeThe Code is as follows:
Bind 127.0.0.1
Allow access only through the IP address 127.0.0.1. In fact, only you can access yourself, and no other machine can access him.
This command must be modified in redis. conf.
Note that
Common Startup Methods: src/redis-server
Change to src/redis-server redis. conf
Because it needs to load the configuration file.
This method is a little bad. I will inevitably have multiple machines accessing a redis service.
2. Set a password to provide remote login
Redis. conf
Find
Requirepass
Write
Requirepass yourpassword
After setting the password, you can log on, but you cannot execute the command.
Copy codeThe Code is as follows:
Src/redis-cli-h 192.168.1.121
Keys *
(Error) ERR operation not permitted
Authorization command
Copy codeThe Code is as follows: auth 123456
Login with Password
Copy codeThe Code is as follows:./redis-cli-h 192.168.1.121-a abcd
Because redis is highly concurrent and only engaged in passwords, attackers may send a large number of password-guessing requests in a short period of time, which is prone to brute force cracking. Therefore, we recommend that the longer the password, the better, for example, 20 characters. (The password is in plain text in the conf file, so you don't have to worry about forgetting it)