Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to login to redis-cli without storing password?

Tags:

redis

I've configured redis-server to use password with requirepass option.

When running redis-cli I have two options to gain access to database.

  1. Use redis-cli -a mypassword command. This stores passsword inbash history. Every time I run it, I need to delete history entry.
  2. Use AUTH mypassword inside redis-cli. This option unfortunately saves your password in redis-cli, and you can look it by pressing up arrow even if you login to redis-cli without any authentication. It is literally accessible without any protection.

What is the proper way to authenticate redis-cli?

like image 527
potato Avatar asked Jan 01 '23 17:01

potato


1 Answers

You may set the password in REDISCLI_AUTH environment variable prior to invoking redis-cli. Once the variable is set, you could access redis-cli without specifying the password with -a switch. The redis-cli would use the password set in REDISCLI_AUTH while connecting to Redis server.

export REDISCLI_AUTH=your_secret_password
redis-cli -h hostname -p portnumber
like image 139
Vivek.N Avatar answered Jan 11 '23 04:01

Vivek.N