I try to suspend my server using dbus and UPower. The server runs Ubuntu LucidLynx 64bit.
While everything works fine if I am sitting directly at the machine, it won't work via ssh. If I connect to the server via ssh and try to suspend the machine using dbus and upower, it gives back
dbus.exceptions.DBusException: org.freedesktop.UPower.GeneralError: not authorized
Could anyone please tell me how to configure dbus in order to allow ssh-users to suspend the machine?
There are two basic ways this can be done and a workaround:
Either you need to modify
/usr/share/polkit-1/actions/org.freedesktop.upower.policy
, set theXDG_SESSION_COOKIE
environment variable to the appropriate value or usepm-suspend
:Modifying
/usr/share/polkit-1/actions/org.freedesktop.upower.policy
Apply this patch:
(To the
<action id="org.freedesktop.upower.suspend">
tag/section), and it'll work too...or
XDG_SESSION_COOKIE
When you're using the desktop, you'll see that
$XDG_SESSION_COOKIE
has one value, but in an ssh session, it has another. StoreXDG_SESSION_COOKIE
e.g. in a .dotfile or something when the desktop starts and source it in your script that needs to do it over ssh.pm-suspend
Or you could just give up on doing it with
dbus
andUPower
and just issuepm-suspend
as root and get it over with! :-)Files under
/usr/share/polkit-1/actions
are not meant to be modified.Create a file named
/etc/polkit-1/localauthority/50-local.d/allow_all_ssh-users_to_upower.pkla