virsh ssh into a guest vm

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

e.g.

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:
$arp
...
$ #2) ssh someone@<IP>

3 Answers

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
    systemctl start 

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.

1

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: - I guess it may help or at least put you in some direction.

2

You may want to take a read of SSHsetup for libvirtd

Seems to do what you want.

1

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

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

You Might Also Like