searchusermenu
  • 发布文章
  • 消息中心
点赞
收藏
评论
分享
原创

通过libvirt使用luks加密盘

2023-06-09 06:39:11
94
0

1. 创建luks加密盘:

▶ qemu-img create -f luks -o cipher-alg=aes-256,cipher-mode=cbc,ivgen-alg=essiv --object secret,data=$password,id=sec0 -o key-secret=sec0 aes.raw 1G

2. 创建qemu访问luks的密钥

▶ cat > luks-secret.xml  <<EOF
<secret ephemeral='no' private='yes'>
    <uuid>14ed6d8b-a940-4314-a1a9-d93e3ff107f8</uuid>  
</secret>
EOF

▶ virsh secret-define secret.xml
▶ virsh secret-set-value 14ed6d8b-a940-4314-a1a9-d93e3ff107f8 $base64-password  # 其中MTIzNDU2是base64方式的,通过printf %s "$password" | base64得到; $password是luks创建时设定的明文密码;这个密码格式和qemu-img create -f luks中指定的格式有关,这儿使用了默认的;
 

3. 给虚拟机xml加上密钥信息

<encryption format='luks'>
	<secret type='passphrase' uuid='14ed6d8b-a940-4314-a1a9-d93e3ff107f8'/>
</encryption>
0条评论
作者已关闭评论
邓****程
2文章数
0粉丝数
邓****程
2 文章 | 0 粉丝
邓****程
2文章数
0粉丝数
邓****程
2 文章 | 0 粉丝
原创

通过libvirt使用luks加密盘

2023-06-09 06:39:11
94
0

1. 创建luks加密盘:

▶ qemu-img create -f luks -o cipher-alg=aes-256,cipher-mode=cbc,ivgen-alg=essiv --object secret,data=$password,id=sec0 -o key-secret=sec0 aes.raw 1G

2. 创建qemu访问luks的密钥

▶ cat > luks-secret.xml  <<EOF
<secret ephemeral='no' private='yes'>
    <uuid>14ed6d8b-a940-4314-a1a9-d93e3ff107f8</uuid>  
</secret>
EOF

▶ virsh secret-define secret.xml
▶ virsh secret-set-value 14ed6d8b-a940-4314-a1a9-d93e3ff107f8 $base64-password  # 其中MTIzNDU2是base64方式的,通过printf %s "$password" | base64得到; $password是luks创建时设定的明文密码;这个密码格式和qemu-img create -f luks中指定的格式有关,这儿使用了默认的;
 

3. 给虚拟机xml加上密钥信息

<encryption format='luks'>
	<secret type='passphrase' uuid='14ed6d8b-a940-4314-a1a9-d93e3ff107f8'/>
</encryption>
文章来自个人专栏
文章 | 订阅
0条评论
作者已关闭评论
作者已关闭评论
0
0