redis Security Management

Redis is no default password, and can only access this machine. Use redis-cli later on even execute arbitrary commands. If you want to open outside the network connection, you need to set a password, while disabling dangerous commands or dangerous commands renamed.


1. Set a password
    (1) Open Redis configuration file, search for the keyword "requirepass"
    (2) the "requirepass" comment this line removed, "foobared" this line is the default password, you can change your password
    (3 ) and restart Redis save profile, it can be found even after the redis-cli Redis can not be used properly
    (4) to normal use Red is, when it is necessary to add a re dis-cl i connected "- a" parameter
        redis - cli -a password
2. open the external network access
    (1) open the configuration file, search for "bind" to find the location of the configuration of the network
    (2) connected to this line of official comment, Redis can be accessed from outside the network
    • in redis-cli in If you want to access Redis outside the network, you need to specify the address and port in the following format:
        Redis Redis-cli -h -a address -p port password
        for example:
            Redis-cli -a -h 192.168.2.10 -p 3129 kingnameisgenius163
    • in Python, Redis order to access the external network, need to change the code:
        Import Redis
        Client = redis.Redis (= Host '192.163.2.10', Port = 3129, password = 'kingnameisgenius')


Disable dangerous command:

    Redis is enabled by default in some commands very high authority. Using these commands, ranging from empty Redis, re-write directly *** mining and even SSH Key public key to control the server.
    Redis by modifying the configuration file, some dangerous commands can be renamed or disabled, thereby reducing security risks.

    (1) Open Redis configuration file and add the following lines:
        the rename-the Command CONFIG ""
        the rename-the Command FLUSHDB sfjafjfaerawe
        the rename-the Command flushAll IWERDF
        the rename-the Command PEXPIRE OKASETTW
        the rename-the Command SHUTDOWN ""
        the rename-the Command BGREWRITEAOF SEWERWEFSDF
        the rename-the Command bgsave ASDFPEWE
        the rename the SAVE-command ASDFKLEWE
        the rename command-the DEBUG ""
    (2) if the command to rename the empty string, disable command.
    For some commands more dangerous but may be used, it can be renamed; for some particularly dangerous commands can be disabled.

Guess you like

Origin blog.51cto.com/5660061/2412501