openstack上cinder卷的加密

目标:

创建并使用加密的cinder卷

准备:

-openstack

过程:

修改配置文件:

将fixed_key的值设置为cinder-volume-key和一组十六位的十六进制的密钥(控制节点和计算节点)

[root@compute ~]# ssh controller                                                    
root@controller's password: 
Last login: Tue May 28 12:10:00 2019 from compute
[root@controller ~]# sed -n 3524,3532p /etc/nova/nova.conf     
[keymgr]

#
# From nova
#

# Fixed key returned by key manager, specified in hex (string value)
fixed_key=cinder-volume-key
fixed_key=0000000000000000

[root@controller ~]# sed -n 2794,2811p /etc/cinder/cinder.conf 
[KEYMGR]

#
# From cinder
#

# Authentication url for encryption service. (string value)
#encryption_auth_url = http://localhost:5000/v3

# Url for encryption service. (string value)
#encryption_api_url = http://localhost:9311/v1

# The full class name of the key manager API class (string value)
#api_class = cinder.keymgr.conf_key_mgr.ConfKeyManager

# Fixed key returned by key manager, specified in hex (string value)
fixed_key = cinder-volume-key
fixed_key = 0000000000000000

重启服务:

[root@controller ~]# systemctl restart openstack-nova-compute
[root@controller ~]# systemctl restart openstack-cinder-volume

[root@compute ~]# systemctl restart openstack-nova-compute
[root@compute ~]# systemctl restart openstack-cinder-volume

创建加密卷类型:

[root@controller ~]# cinder type-create luks
+--------------------------------------+------+-------------+-----------+
|                  ID                  | Name | Description | Is_Public |
+--------------------------------------+------+-------------+-----------+
| bd278099-ad80-4f54-b1da-e0734ee33cba | luks |      -      |    True   |
+--------------------------------------+------+-------------+-----------+
[root@controller ~]# cinder encryption-type-create --cipher aes-xts-plain64 --key_size 512 --control_location front-end luks nova.volume.encryptors.luks.LuksEncryptor    
+--------------------------------------+-------------------------------------------+-----------------+----------+------------------+
|            Volume Type ID            |                  Provider                 |      Cipher     | Key Size | Control Location |
+--------------------------------------+-------------------------------------------+-----------------+----------+------------------+
| bd278099-ad80-4f54-b1da-e0734ee33cba | nova.volume.encryptors.luks.LuksEncryptor | aes-xts-plain64 |   512    |    front-end     |
+--------------------------------------+-------------------------------------------+-----------------+----------+------------------+

创建cinder卷:

未加密:[root@controller ~]# cinder create --name unencrypted 1 
加密:[root@controller ~]# cinder create --name encrypted --volume-type luks 1 

挂载到云主机进行测试:

加密卷:

[root@controller ~]# nova volume-attach iaas 89f2cc72-435e-4136-b32f-44acdd96a8a7
+----------+--------------------------------------+
| Property | Value                                |
+----------+--------------------------------------+
| device   | /dev/vdb                             |
| id       | 89f2cc72-435e-4136-b32f-44acdd96a8a7 |
| serverId | 3089a676-1394-4e0b-bad7-e9ed1f43e676 |
| volumeId | 89f2cc72-435e-4136-b32f-44acdd96a8a7 |
+----------+--------------------------------------+

未加密:

[root@controller ~]# nova volume-attach iaas c4fa8087-e648-4ee4-ba24-be8d56835d98
+----------+--------------------------------------+
| Property | Value                                |
+----------+--------------------------------------+
| device   | /dev/vdc                             |
| id       | c4fa8087-e648-4ee4-ba24-be8d56835d98 |
| serverId | 3089a676-1394-4e0b-bad7-e9ed1f43e676 |
| volumeId | c4fa8087-e648-4ee4-ba24-be8d56835d98 |
+----------+--------------------------------------+

测试:
到云主机里向卷内写入数据

[root@xiandian ~]# echo "encrypted /dev/vdb Hello,world" >> /dev/vdb 
[root@xiandian ~]# echo "unencrypted /dev/vdc Hello,world" >> /dev/vdc 

到cinder卷所在节点验证:
未加密的卷信息就会暴露出来

[root@compute ~]# strings /dev/mapper/cinder--volumes-volume--* | grep "Hello,world"
unencrypted /dev/vdc Hello,world
评论 9
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

小小之食人魔

学习技术是为了早点下班!

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值