6 Remote shell

With Maemo PC Connectivity, it is possible to execute shell commands on another computer across network. That is, you can remotely execute shell commands on maemo device from your host PC and vice-versa. For that, you have to install maemo-pc-connectivity meta package on maemo device and host-pc-connectivity package on host PC (Linux, Windows and Mac OS). Next, it will be described how to use the remote shell tools available on Maemo PC Connectivity. To simplify, it is assumed that you already have a Usb network between maemo device and host PC.

Note: on host PC, you should type the commands bellow at terminal on Linux and Mac OS and at Cygwin shell on Windows.

6.1 SSH

Secure Shell (SSH) is a network protocol that allows data to be exchanged using a secure channel between two networked devices. It was designed as a replacement for Telnet and other insecure remote shells, which send information, notably passwords, in plain text, leaving them open for interception. With SSH, you can remotely execute programs on maemo device from your host PC and vice-versa. Next, it will be described the steps to access your maemo device from host PC.

To avoid typing password every time, the remote machine needs to authorize the local machine identity. The process works on both direction, so the meaning of remote and machine will change. Here, the remote machine will be the maemo device and the local machine will be the host PC. It follows the needed steps:

You should apply the steps above for every local and remote user combination. For example: if you want to connect to root and user accounts on maemo device from root account on host PC, you need to generate a key pair for root account on host PC and copy the public key to database of authorized keys (root and user accounts) on maemo device

On host-pc-connectivity package, it is provided a tool named ssh-key-exchange that exchanges SSH public keys automatically. Thus, SSH will not ask password every time. For that, you should execute the following command:

ssh-key-exchange -l local_ip_address -r remote_ip_address 
-u remote_username

After exchanging keys, the next SSH connections will not require password.


Scratchbox Remote Shell (SBRSH) is a remote shell solution such as SSH. It allows you to execute programs on maemo device from host PC, but using the host PC file system, instead of maemo device file system. The following steps show how SBRSH works:

  1. The user configures SBRSH client on host PC giving the folders to be remotely mounted on maemo device, usually home folder
  2. The user executes sbrsh my_app on host PC to test if the application is working properly on maemo device
  3. SBRSH client (on host PC) sends the request to SBRSH server (on maemo device)
  4. SBRSH server mounts host PC folders on maemo device according to SBRSH configuration files (defined on step 1)
  5. SBRSH server (on maemo device) executes the command (in this example, my_app) and redirects the standard output to SBRSH client (on host PC)
  6. SBRSH client (on host PC) receives and shows the output to user

6.2.1 Configuring Maemo

It follows the steps to configure SBRSH through Maemo PC Connectivity:

Otherwise, you can setup SBRSH manually. For that, you have to edit the following configuration files:

In this file, you can setup SBRSH basic functionality by uncommenting lines and configuring variables to different values. Some useful options are:

DEBUG: enable debug logging to /var/log/sbrshd.log file or to the file defined at DEBUG_FILE. This can be useful if you are having trouble while connecting. Also, you can execute sbrshd -enable-debug or sbrshd -disable-debug to toggle debug option dynamically.

NO_SANDBOX: this option became deprecated since version sbrshd-7.6maemo3, once SBRSH client can switch from SANDBOX and NO_SANDBOX by passing -s or -n option, respectively. It follows the meaning of SANBOX and NO_SANDBOX:

  1. SANDBOX - allows remote execution of commands on maemo device considering the local environment from where the command was executed. This means that the file system from your host PC, usually the scratchbox rootstrap, is exposed to maemo device
  2. NO_SANDBOX - the default mode. The remote execution of commands in maemo device occurs against its own file system

EXPIRATION: defines in minutes how long sbrshd will wait before unmount shares. Since the typical sandboxed usage of sbrshd will cause a significant delay the first time you connect (because most of the shared libraries and shell related binaries from the host PC must be passed over the network), you will usually set a long expiration time.

By default, the installation of maemo-pc-connectivity meta package has configured these options to no debugging, sandboxed enabled, and 15 minute expiration.

If you changed this file, you should restart the SBRSH daemon to get the configuration working:

 # /etc/init.d/sbrsh restart
In this file, you have to give access rights to host PC on sbrshd. You need to manually edit this file and add an entry for your host PC IP Address. Just add the host PC IP address as a new line. For example:

Note: SBRSH does not use a secure protocol, so be judicious in granting access!

6.2.2 Configuring Host PC

In this example, SSH will be used to configure SBRSH client. So, you can use ssh-key-exchange as described in section 6.1 to avoid SSH requiring password every time.

In order to use SBRSH client, you need a configuration file to select the targets of the devices and which file systems they export from host. By default, the file used is  /.sbrsh, but you may override it by using the following command sbrsh -c <file_name>. The first target defined on configuration file is used by default, but you may override it by using the following command sbrsh -t <target_name>. Next, it will be explained the SBRSH configuration file format

6.2.3 CPU Transparency

In CPU transparency mode, the SBRSH configuration file is determined by SDK target location and the first target is used by default. You can follow the next steps to use SBRSH in CPU transparency mode on scratchbox:

6.2.4 Testing

If you changed SSH keys with root user on maemo device, you need to specify this on command line. Run the following command on host PC to see if the mount works:

  $ sbrsh -r 0,0,root ls /
    bin cdrom etc home lib mnt proc sbin sys usr
    boot dev floppy initrd media opt root srv tmp var

Also, you can use -s or -n option to turn on/off sandbox mode on server, respectively:

  $ sbrsh -n -r 0,0,root ls /
    bin cdrom etc home lib mnt proc sbin sys usr
    boot dev floppy initrd media opt root srv tmp var

  $ sbrsh -s -r 0,0,root ls /
    bin cdrom etc home lib mnt proc sbin sys usr
    boot dev floppy initrd media opt root srv tmp var

6.2.5 Troubleshoot

You can get some errors while using SBRSH. Next, it will be described some of them:

Walter 2009-12-21