Ssh – enable ssh over virtual machines running on kvm

kvm-virtualizationssh

I am trying to connect to a virtual machine running on KVM hypervisor from a host machine (Ubuntu 14.04) through ssh, but it is giving me the following error:

ssh: connect to host 10.117.82.2 port 22: Connection refused

How can I enable ssh on the guest virtual machine? I've installed the virtual machine using virt-install. So, is there any provision in virt-install for enabling ssh?

Best Answer

One straightforward way to apply the initial configurations such as SSH installation is to use VNC.

  1. Use the following command to get the list of VMs

sudo virsh list --all

  1. Open the XML config file:

sudo virsh edit YOUR_VM_NAME

  1. Append the following line before final :
<graphics type='vnc' port='-1' autoport='yes' listen='192.168.1.5' passwd='YOUR-PASSWORD-HERE' keymap='en-us'/>

where the listen address is the IP address of the server, not the guest OS

  1. Use a VNC client to connect to the guest OS