Showing posts with label ssh. Show all posts
Showing posts with label ssh. Show all posts

Monday, October 25, 2010

SSH agent forwarding in Scratchbox

I usually have the Maemo SDK running inside a VM - either completely remote or on the same machine (so I can have a 32-bit minimal Debian install containing Scratchbox independent of the host system). I can then SSH into the development VM from my working machine using public key authentication and the SSH agent. I also have agent forwarding set up, so that I can SSH from the SDK machine directly to the N900 (to deploy binaries and .debs) or to some server requiring SSH access (e.g. drop.maemo.org) without having to generate lots of keys and distributing the key to all kinds of different machines.

Using -A (or ForwardAgent yes in .ssh/config) when SSHing into the SDK machine makes it possible to connect to other machines from it, utilizing your SSH key. This sadly does not work when starting scratchbox, because it opens a new environment, and the $SSH_AUTH_SOCK environment variable is lost. To fix this, I simply write the contents of this variable into a file accessible from Scratchbox and then export this variable in the Scratchbox login script. I usually also have a symlink in $HOME pointing to the SDK $HOME:

ln -s /scratchbox/users/$USER/home/$USER ~/sdk

With this in place, I can now edit the "normal" user's login script by adding the following line at the end of .bashrc:

echo $SSH_AUTH_SOCK >~/sdk/.ssh_auth_sock

Scratchbox has its own login script (also called .bashrc, but sitting in the Scratchbox home folder), so we edit this and add the following line:

export SSH_AUTH_SOCK=`cat .ssh_auth_sock`

After this, logout of Scratchbox, logout of the SSH session and then connect again with SSH forwarding:

ssh user@maemosdk -A
scratchbox
ssh-add -l

The last command should display the fingerprint of your SSH key. You can now connect to remote hosts from within your Scratchbox session while your SSH key still resides only on your local machine, loaded into the SSH agent.

Saturday, November 8, 2008

Get Avahi working on Maemo

Avahi is a service discovery service (phew!) for local networks (Apple calls this technology Bonjour). Among other things, its most basic functionality is to allow you to have a ".local" domain for your home network managed in a peer-to-peer fashion. This way, you do not have to remember the IP of your N8x0, but can use "threepwood.local" (if your N8x0 is named "threepwood").

The packages that need to be installed are "avahi-daemon" and "avahi-dnsconfd". There are some other avahi packages available (including GUIs) that you might want to try out. After installing, you should be able to ping your N8x0 from your Linux (with Avahi installed) or Mac OS X (works out of the box) machine.

The only problem: Avahi's daemons and D-Bus start in the same order (S20) on startup, and therefore Avahi gets to be first (alphabetical order), so you have to get root on your tablet and rename all S20avahi-* files in /etc/rc2.d/ to S21avahi-*. This way, D-Bus gets started first and after that, Avahi can start successfully (if Avahi is started before D-Bus, it won't work!).

After that, you can disable the HomeIP applet and start reading and typing IPs around your home network, but let Avahi/Bonjour do the hard work and you just type the easy-to-remember ".local" if you want to SSH to your tablet.

You can do even more fun things when you put "ssh.service" into /etc/avahi/services/ and install "service-discovery-applet" on your Gnome Desktop. This way, you can directly connect via SSH/SFTP to your tablet without needing to remember anything.

What are your uses for Avahi?