Skip to main content

Redis Security - Bảo mật trong Redis database

Redis database có cơ chế bảo mật xác thực khi client kết nối và thực thi lệnh trên Redis. Để bật tính năng bảo mật, bạn cần thiết lập mật khẩu trong config file

Kiểm tra cấu hình xác thực:

127.0.0.1:6379> CONFIG get requirepass 
1) "requirepass" 
2) "" 

Thiết lập xác thực:

127.0.0.1:6379> CONFIG set requirepass "tutorialspoint" 
OK 
127.0.0.1:6379> CONFIG get requirepass 
1) "requirepass" 
2) "matkhau" 

Sau khi thiết lập mật khẩu, client kết nối đến Redis mà không xác thực sẽ nhận được thông báo lỗi: (error) NOAUTH Authentication required

Cú pháp xác thực:

127.0.0.1:6379> AUTH password 

Ví dụ:

127.0.0.1:6379> AUTH "tutorialspoint" 
OK 
127.0.0.1:6379> SET mykey "Test value" 
OK 
127.0.0.1:6379> GET mykey 
"Test value"