Turn: Redis Login with authentication password

Source: Internet
Author: User
Tags redis cluster redis server

The Redis default configuration does not require password authentication, which means that the connection can be used as long as the host and port of the connected Redis server are correct. This has some security problems, so you need to enable the Redis authentication password to increase the security of the Redis server.

1. Modify the configuration file

The Redis profile is on by default /etc/redis.conf , and it finds the following line:

#requirepass foobared

Remove the previous comment and modify it to the desired password:

Requirepass MyPassword (where MyPassword is the password to set)
2. Restart Redis

If Redis is already configured as a service service, it can be restarted in the following ways:

Service Redis Restart

If Redis is not configured as a service service, it can be restarted in the following ways:

/USR/LOCAL/BIN/REDIS-CLI shutdown/usr/local/bin/redis-server/etc/redis.conf
3. Login Verification

After setting up the Redis authentication password, the client will need to -a enter the authentication password using the parameter, but it can log on successfully without any operation permission. As follows:

$./redis-cli-h 127.0.0.1-p 6379127.0.0.1:6379> Keys * (Error) Noauth authentication required.

Login with password authentication and verify the operation permissions:

$./redis-cli-h 127.0.0.1-p 6379-a mypassword127.0.0.1:6379> config get requirepass1) "Requirepass" 2) "MyPassword"

See the output similar to the above, indicating that the Reids password Authentication configuration was successful.

In addition to logging in as above, use the -a parameters to enter the login password. You can also do this without specifying it after the connection:

4. Configure password at command line client (before Redis restart)

redis.confThis configuration requires you to restart Redis by configuring a password, as described earlier. You can also configure passwords through the command line client, which does not have to restart Redis. The configuration is as follows:

127.0.0.1:6379> config set Requirepass newpasswordok127.0.0.1:6379> config get requirepass1) "Requirepass" 2) " NewPassword "

Note : using the command line client to configure the password, the redis.conf password in the configuration file will still be used after the Redis restart.

5. Use the authentication password in the Redis cluster

If the Redis server, the cluster is used. In addition to master configuring passwords in, you need to slave configure them in. slaveLocate the following line in the configuration file, remove the comment and modify the master same password:

# Masterauth Master-password

Article turned from: http://itbilu.com/linux/management/Ey_r7mWR.html

Turn: Redis Login with authentication password

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.