Is there anyway that I can ssh into a guest vm through virsh instead of find the ip address of the guest vm?


what I want is ssh into a guest like this way :

$virsh ssh_or_somwthing <domain>

but not like this:

$ #1) find the guest vm's IP address:
$ #2) ssh someone@<IP>

3 Answers 3


Jacek has the right answer, but just to lay out some of the specifics:

  1. Log into the VM using the KVM GUI
  2. On the VM command line, type in:

    systemctl enable serial-getty@ttyS0.service
    systemctl start serial-getty@ttyS0.service

You will be asked multiple times to enter your password/accept.

  1. Reboot the VM
  2. Then, from the terminal on your main machine, type in:

    sudo virsh console your_vm_name_here

Obviously replacing "your_vm_name_here" with whatever the VM name is.

Then you can "ssh" directly into the VM using virsh.

  • 5
    This allows you to access the VM via a terminal, but this has nothing to do with SSH.
    – Jounathaen
    Dec 28, 2019 at 17:37

I'm not sure about it, but I think you're looking to configure console access to the guest? It may not be the only solution (not following virsh very actively and all this stuff) - but you can setup serial console on your guest, configure your supervisor and then use virsh console domain.

Anyway - have a look at this: https://help.ubuntu.com/community/KVM/Access - I guess it may help or at least put you in some direction.

  • thanks :) it seems that console access is using telnet(I'am not sure about it) ?
    – gansteed
    Jan 23, 2015 at 12:20
  • Not really - telnet is different story. It's actually serial connection (kind of virtualized here)
    – Jacek
    Jan 23, 2015 at 14:23

You may want to take a read of SSHsetup for libvirtd


Seems to do what you want.

  • 1
    The link you provided shows how to set up ssh communications to libvirt running on another system. This uses ssh just as a tunnel between virsh (or virt-manager) and libvirt on different machines. The OP is looking to send console commands directly through virsh to the VM, using virsh as a proxy or tunnel into the VM, rather than via ssh to the VM itself. This would be useful for running a VM with no networking, but still have effectively a serial console into the VM. Sep 9, 2021 at 18:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.