通过webvirtmgr管理平台配置SSH连接

最近有两台新的虚拟化主机安装好libvirtd后发现用以前的TCP连接方式会导致webvirtmgr无法和受控主机通信,显示验证失败,大概查了下是yum源中的 libvirt 更新了,默认加密模式变更了,导致使用saslpasswd2 -a libvirt 命令生成的**无法通过验证,折腾了下没搞好,就干脆切换到SSH方式进行控制。

系统环境:CentOS Linux release 7.3.1611 (Core)

虚拟化:libvirt 3.2.0 版本

在webvirtmgr服务器(服务端)生成**

[[email protected]_master ~] cd /home
[[email protected]_master home] mkdir nginx  #因为nginx用户在创建的时候是设置的sbin/nologin 所以这里需要手动创建家目录
[[email protected]_master home] chown nginx.nginx nginx/
[[email protected]_master home] chmod 700 nginx/ -R
[[email protected]_master home] su - nginx -s /bin/bash  
-bash-4.2$ ssh-******   ---期间输入yes后直接回车,回车
-bash-4.2$  touch ~/.ssh/config && echo -e "StrictHostKeyChecking=no\nUserKnownHostsFile=/dev/null" >> ~/.ssh/config
-bash-4.2$  chmod 0600 ~/.ssh/config

在kvm(受控端)服务器上配置webvirt用户

[[email protected]_10 home] useradd webvirtmgr
[[email protected]_10 home] echo "123456" | passwd --stdin webvirtmgr
[[email protected]_10 home] groupadd libvirt
[[email protected]_10 home] usermod -G libvirt -a webvirtmgr

在webvirtmgr服务器(服务端)上,将ssh-key上传到kvm服务器上

[[email protected]_master home] su - nginx -s /bin/bash
-bash-4.2$ ssh-copy-id   [email protected]

在kvm(受控端)服务器上配置 libvirt ssh授权

[[email protected]_10 home] vim /etc/polkit-1/localauthority/50-local.d/50-libvirt-remote-access.pkla
[Remote libvirt SSH access]
Identity=unix-user:webvirtmgr
Action=org.libvirt.unix.manage
ResultAny=yes
ResultInactive=yes
ResultActive=yes
[[email protected]_10 home] chown -R webvirtmgr.webvirtmgr /etc/polkit-1/localauthority/50-local.d/50-libvirt-remote-access.pkla

重启 libvirtd 服务

[[email protected]_10 home] systemctl restart libvirtd

webvirtmgr 控制台中添加主机

通过webvirtmgr管理平台配置SSH连接

干货:《Linux就该这么学》