We have a virtual win7 machine that needs to be rebooted remotely from time to time. We created a restricted user account with the shell set to rbash so a user can ssh in and reboot the virtual machine via virsh when needed.

user@machine:~$ echo $SHELL
user@machine:~$ virsh
Welcome to virsh, the virtualization interactive terminal.

Type:  'help' for help with commands
       'quit' to quit

virsh # list
error: failed to connect to the hypervisor
error: no valid connection
error: Failed to connect socket to '/var/run/libvirt/libvirt-sock': Permission denied

virsh and virt-top do run, but the user can't do anything inside virsh. How can we allow this user to run virsh commands from an rbash shell?

  • I think this is not rbash related, but an ordinary permission-problem. The user in question has to have read/write permissions on the socket it tries to open. Commented Mar 21, 2016 at 16:55

2 Answers 2


Andreas is correct, it is not an rbash problem; adding user to the group libvirtd solves the problem.

  • FWIW, as an alternative to the ssh + rbash approach you could simply connect remotely to libvirtd via virsh - see e.g. libvirt.org/uri.html and especially the section about remote URI's: libvirt.org/uri.html#URI_remote
    – doktor5000
    Commented Mar 22, 2016 at 7:45
  • The comment from @doktor5000 should be the accepted answer.
    – John
    Commented Mar 23, 2016 at 15:35

Adding my comment as an answer, as using ssh to connect to the host, and then using a dedicated user running rbash seems only a workaround to me.

As a less hackish alternative to one could simply connect remotely to libvirtd via virsh.
See e.g. https://libvirt.org/uri.html and especially the section about remote URI's

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .