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 surendra@192.168.100.129

Output:

ssh surendra@192.168.100.129
surendra@192.168.100.129’s password:
Last login: Mon Feb 25 08:47:02 2013 from 192.168.100.1
[surendra@www ~]$ 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

The following two tabs change content below.
Mr Surendra Anne is from Vijayawada, Andhra Pradesh, India. He is a Linux/Open source supporter who believes in Hard work, A down to earth person, Likes to share knowledge with others, Loves dogs, Likes photography. He works as Devops Engineer with Taggle systems, an IOT automatic water metering company, Sydney . You can contact him at surendra (@) linuxnix dot com.