Redis as a high-speed database, on the Internet, must have a corresponding security mechanism to protect.
1. A more secure approach is to use an IP-bound approach for control.
The code is as follows |
Copy Code |
Bind 127.0.0.1 |
Indicates that access is only allowed through 127.0.0.1 this IP address. Then in fact only oneself can access oneself, the other machine cannot access him.
This order is to be changed in redis.conf.
Attention here, please.
Our common startup mode is Src/redis-server
To
The code is as follows |
Copy Code |
Src/redis-server redis.conf |
Because it needs to load the configuration file.
This method is not very good, I will inevitably have more than one machine access to a Redis service
2. Set password to provide remote login
The code is as follows |
Copy Code |
Redis.conf Found it Requirepass
|
Write on
Requirepass YourPassword Set the password and found that it could be logged in, but could not execute the command.
The code is as follows |
Copy Code |
Src/redis-cli-h 192.168.1.121 Keys * (Error) ERR Operation not permitted
|
Authorization command
Auth 123456 Login with password method
./redis-cli-h 192.168.1.121-a Hzhutid Because Redis concurrency is extremely strong, only the password, the attacker may send a large number of guessing password requests in the short term, it is easy to brute force, so the proposed password longer the better, such as 20-bit. (The password in the Conf file is plaintext, so don't worry yourself will forget)