Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top


I'd like to access a D-Bus system service from another machine, knowing only machine's IP address and the service to connect to.

What I have recently found is Gabriel (D-Bus over SSH). I have compiled its GIT version (hosted on Sourceforge) and this seems to work, but I keep getting a problem with the lack of "keep-alive". This means that after some period of inactivity the SSH tunnel fails to forward D-Bus requests to remote PC and I must restart Gabriel.

Since Gabriel uses socat on the PC it connects to, I've just had an idea of using socat also on local PC (replacing Gabriel with it).


  • Could anyone more familiar with setting up "socat" confirm that solution please?
  • Could such solution handle many client applications connecting to the same remote D-Bus service at once?
  • As it is unneccessary for me to have the connection secured - would using "socat" on both sides make the connection significantly faster (in opposite to Gabriel's SSH tunnel, if the SSH gives too much overhead)?
  • Does anyone have any better solution for accessing D-Bus remotely maybe?

Any comments appreciated.

share|improve this question
up vote 2 down vote accepted

I'll post an answer to my own question, as I have worked out a working solution.

Note: I have sacrificed all security via SSH as it wasn't needed for development in my own LAN. Changing DBus to listen on TCP instead unix sockets was also not possible.

Step 1

On the remote host with an example IP address (and to which D-Bus I'd like to have access to) I run:

   socat TCP-LISTEN:7272,reuseaddr,fork UNIX-CONNECT:/var/run/dbus/system_bus_socket

Now socat listens for connections on 7272 port and creates a separate thread for each client. This allows multiple connections at the same time.

Step 2

On local machine (which I'd like to connect to remote D-Bus) I run:

   socat ABSTRACT-LISTEN:/tmp/custom_dbus_name,fork TCP:

This connects to the port exposed remotely with socat and creates a local abstract socket to which we can connect to.

Sample usage


import dbus

sysbus = dbus.bus.BusConnection("unix:abstract=/tmp/custom_dbus_name")
proxy_obj = sysbus.get_object('', '/com/some/service/name')
my_interface = dbus.Interface(proxy_obj, dbus_interface = '')



One can also use D-Feet to browse remote D-Bus services and their methods. It can be done with "File / Connect to other bus" menu option and putting your custom abstract socket name defined in second step.

share|improve this answer

SSH has in inbuilt keep alive mechanism. May be you use that to ensure you session is not closed?

To enable keep alive in ssh,

Either Add the following line to the /etc/ssh/ssh_config file for global configuration:

ServerAliveInterval 60

Or add the following lines to ~/.ssh/config (create if required) for user configuration

Host *
 ServerAliveInterval 60

You can also use per host configuration by appending hostname to the * , eg :

Host *
 ServerAliveInterval 60

Where the 60, represents the interval in seconds after which the keep alive/no-op code is sent. Also, the space in the second line is important.

share|improve this answer
Thank you for submission. Unfortunately it didn't help. I've updated the global configuration, restarted sshd, established connection then and waited some time. SSH session has had expired and "Gabriel" had the session channel closed already. – schedar Aug 6 '12 at 7:28

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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