When I installed Centos7, then at a later date Ubuntu LTS, I wanted to play about with KVM, it’s pretty easy to install, there are many tutorials on that about, so I won’t get into it here. I like to use virt-manager to control machines, but I’ve noticed on the latest centos and Ubuntu server, when you’re trying to connect to the console, it’s constantly asking you for the password, there isn’t a way around this by default. I’ve lost my temper a few times which is why I’ve reinstalled my server os. What I should have done is sat down and had a little think/reseach and that’s what I did. And to cut a long story short, it’s bloody easy when you know how. It might not work for you, but for me, it’s great.
On the machine virt-manager is used, you need to generate an SSH Keypair
ssh-keygen -t rsa
Once you’ve done that you need to use ssh-copy-id to move the key to the root user [of if you’re using ubuntu, the user] of the KVM Host
ssh-copy-id -i ~/.ssh/id_rsa.pub firstname.lastname@example.org
You should now be able to ssh to the kvm host from your desktop without it asking you for a password, try it.
ssh -l root email@example.com
If you need to add the key to the SSH agent, then you can use this command
Once all this is done, you should be able to connect to the console of the VM using virt-manager and it shouldn’t ask you for a password and just take you straight to the console. Result.