Redis Configuration: Set Password and Modify Port

Source: Internet
Author: User
Keywords redis port set redis password 6379 redis
If redis is installed on the intranet, it does not matter if the password is not set. However, if it is put on the Internet, it is still necessary to set the password and modify the default port, especially when installing redis under root authority. In this way, it is a matter of minutes for the server to be attacked, so the following introduction sets the password and modify the port for redis:

change Password
1. Permanent setting, that is, to write a password in the configuration (recommended)
Find #requirepass foobared in redis.conf configuration of redis, remove ‘#’, and change foobared to the password to be set, such as:
requirepass test123. In this way, you need to restart the redis service to set up successfully.

Second, set a temporary new password, no need to restart, the temporary password is invalid after restart
After entering redis-cli, set as follows
Set password: 127.0.0.1:6379> config set requirepass test123

Query password:
redis 127.0.0.1:6379> config get requirepass
(error) ERR operation not permitted

Password validation:
redis 127.0.0.1:6379> auth test123
OK

Check again:
redis 127.0.0.1:6379> config get requirepass
1) "requirepass"
2) "test123"

ps:
The AUTH command, like other redis commands, is not encrypted; it cannot prevent an attacker from stealing your password on the network;
The goal of the authentication layer is to provide an additional layer of protection. If the firewall or the system used to protect redis fails to defend against external attacks, external users cannot access redis if they do not pass password authentication.

Modify the port

Go to the redis.conf file and change the 6379 here to the desired port, such as port 6378, then restart redis. We use redis-cli to access the default port 6379, so we have to specify the port, use the command redis-cli -p 6378 so that we can successfully connect to our modified port.

ps
End redis:
1. Shutdown under redis-cli
2. ps -ef|grep redis find the pid of redis, use kill -9 pid
Start redis:
./redis-server ./redis.config
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.