天天看点

No.01 AWS Redis 启用TLS和AUTH

一、首先创建aws elc时,启用tls,terraform code 

resource "aws_elasticache_replication_group" “test”{

  transit_encryption_enabled = true

}

二、编译redis-cli,env = ubuntu 18.0.4

参考aws doc : 

https://docs.aws.amazon.com/zh_cn/amazonelasticache/latest/red-ug/in-transit-encryption.html

1.安装依赖包

$ apt-get update

$ apt-get upgrade

$ apt-get install gcc openssl tcl clang wget

$ apt-get install libssl-dev     // 其实安装的是 opnessl-devel

$ apt-get install libjemalloc-dev // 其实安装的是 jemalloc-devel

// tcl-devel ,ubuntu找不到,至今也未安装成功

2.编译 redis-cli,必须是redis 6.0版本,才能支持tls

$ wget http://download.redis.io/redis-stable.tar.gz

$ tar zxvf redis-stable.tar.gz

$ cd redis-stable/

$ make distclean

$ make redis-cli cc=clang build_tls=yes

$ install -m 755 src/redis-cli /usr/local/bin/

三、使用aws elc cli启用auth(elc必须已经启用了tls)并验证:注意参数 --tls 的位置

// auth-token-update-strategy rotate,因为创建之初,无法设置auth,所以这里必须指定rotate策略,使得无密码和设定的密码同时可用状态

aws elasticache modify-replication-group --replication-group-id "创建的elc name" --auth-token "密码:必须符合aws密码要求" --auth-token-update-strategy rotate --apply-immediately

// 设定为仅用密码登录

aws elasticache modify-replication-group --replication-group-id "创建的elc name" --auth-token "必须是上面已经设定的密码" --auth-token-update-strategy set --apply-immediately

// 验证:如果elc是集群模式,必须使用参数 -c 

redis-cli -c -h hostname --tls -a "auth token" -p port