Webvirtmgr配置SSH鏈接(解決centos7,TCP認證失敗)


系統環境:CentOS Linux release 7.5.1804 (Core)nginx

虛擬化:libvirt 3.9.0 版本web


操做以前必須搞清楚:vim


一、 服務端 webvirtmgr 的管理用戶是誰?bash

ps -ef|grep webvirtmgr      #官方通常建議是nginx服務器


二、 客戶端 libvirt 的管理用戶是誰?ssh

經過webvirtmgr管理界面上SSH登陸時所輸入的用戶名ide

如:webvirtmgrspa




一、 在webvirtmgr服務器(服務端)生成密鑰unix

#建立nginx宿主目錄rest

cd /home

mkdir nginx #由於nginx用戶在建立的時候是設置的sbin/nologin 因此這裏須要手動建立家目錄

chown nginx.nginx nginx/

chmod 700 nginx/ -R


#切換到nginx用戶下生成祕鑰對

su - nginx -s /bin/bash

-bash-4.2$ ssh-keygen ---期間輸入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用戶

[root@kvm_10 home] useradd webvirtmgr

[root@kvm_10 home] echo "123456" | passwd --stdin webvirtmgr

[root@kvm_10 home] groupadd libvirt

[root@kvm_10 home] usermod -G libvirt -a webvirtmgr


三、 在webvirtmgr服務器(服務端)上,將ssh-key上傳到kvm服務器上

su - nginx -s /bin/bash

-bash-4.2$ ssh-copy-id webvirtmgr@10.0.0.66


四、 在kvm(受控端)服務器上配置 libvirt ssh受權

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


chown -R webvirtmgr.webvirtmgr /etc/polkit-1/localauthority/50-local.d/50-libvirt-remote-access.pkla


#重啓 libvirtd 服務

systemctl restart libvirtd


五、 webvirtmgr 控制檯中添加主機

image.png

相關文章
相關標籤/搜索