In this post we will see on how to connect to a VM through number of ways such as remote connection SSH, VNC and console) and through locally in Hypervisor using tools like virt-viewer and virt-manager. Some of the posts which we already covered are..

As mention above we can connect to a guest VM using many techniques available. These are divided in two types

  1. Local connection
  2. Remote connection

Connect VM locally in KVM hypervisor: We can connect/view guest machine when we are on KVM hypervisor it’self. Some tools which we can use to connect through are virt-manager and virt-viewer

Example1 : Connect Guest Virtual machine through virt-manager. Execute below command in the terminal of a Hypervisor and you will see virt-manager GUI, from there you can manage different VM’s and view the VM’s as well

virt-manager

Virt-manager1

Virt-manager-VMstart

VM booting

vm login

Example2: We can connect using virt-viewer as well to a specific machine.

virt-viewer -c qemu:///system BaseMachine

-c is to connect to a specific emulator, here it is qemu is the connecting protocol. BaseMachine is my VM name.

Example3: Connect guest VM using vncviewer command. In order to connect through VNC we have to check where and on which port our VM is running by using virsh domdisplay command

virsh domdisplay BaseMachine
or
virsh vncdisplay Clusterbase

Output:

vnc://127.0.0.1:0

Now connect to this IP and port

vncviewer 127.0.0.1:1

or we can combine vncviewer and virsh vncdisplay command as show below.

vncviewer $(virsh vncdisplay Clusterbase)

Example5: We can even connect through SSH connection too.

ssh [email protected]

Output:

ssh [email protected]
[email protected]’s password:
Last login: Mon Feb 25 08:47:02 2013 from 192.168.100.1
[[email protected] ~]$ ifconfig
eth0 Link encap:Ethernet HWaddr 52:54:00:EC:35:BF
inet addr:192.168.100.129 Bcast:192.168.100.255 Mask:255.255.255.0
inet6 addr: fe80::5054:ff:feec:35bf/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:1119 errors:0 dropped:0 overruns:0 frame:0
TX packets:66 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:75775 (73.9 KiB) TX bytes:9226 (9.0 KiB)

Example6: We can even connect through console by editing ttyS0 terminal located in /etc/init/ttyS0 file.

In our next post we will see on how to connect to a virt-manager to manager VM’s