Using scp and ssh from the Pogoplug
A standard Pogoplug will have dropbear installed. This is the stripped-down version of [open]sshd, the secure shell daemon. Unfortunately, the ssh client is not provided, but scp is. However, whenever you try to use scp from /usr/bin it will tell you that /usr/bin/dbclient is missing. Also, there is no ssh program. All this is easily remedied by ipkg install openssh. If you want to go for a simpler solution, then pick up this dbclient program and put it in /usr/bin. Don’t forget to first make / writable with mount -o rw,remount /.
You might as well then create the symbolic link for ssh in /usr/bin:
ln -s dbclient ssh.
Now you have scp and ssh capabilities without the need of full /opt support.
By the way, if you want to use scp from another machine into the pogoplug, or you’d like to sshfs-mount the Pogoplug filesystem, then you need an sftp-server. This program is available as part of openssh and there’s an ipk package for it; simply follow these steps:
# ipkg install openssh-sftp-server
# mount -o rw,remount /
# mkdir /usr/libexec
# cp /opt/libexec/sftp-server /usr/libexec/
(Check that the file is executable for all, chmod a+x sftp-server)
# mount -o ro,remount /
Update on 1/4/2011: scp might not work for a regular user; it’s fine for root. This is due to wrong permissions of /dev/tty. Try chmod go+rw /dev/tty (after remounting / writable, of course). Also, dbclient might complain about missing libz.so. That was my mistake; I uploaded a fresh dbclient.
SSHFS
I think networking is the greatest invention in computers.
Having machines talk to each other lies at the heart of the success of the Internet. The plug already does a good job: it supports several communication protocols right out of the box. But what I find missing is the ability to securely mount a file system of another machine on a directory of the Pogoplug. I am talking about sshfs. This wonderful and simple program makes any remote directory appear as a local directory. Moreover you don’t have to be root to do the mount. I use sshfs to access a NAS device that I have set up with family in France. Once the mount is up, I can use all the usual file system commands to copy, move and delete files and directories on the remote machine. Note that the communication of data goes through an ssh tunnel; this means that it is encrypted. The access to the remote host is authenticated with your password of the account you have on the remote host. It is even possible to create a ssh key pair and use that instead of a password.
Unfortunately there is no optware ipkg package for sshfs. So how did I get it? I decided to build it natively. This means you need a compiler and related software on your plug. Too much work you say? Well, the good thing is that now that I have the binary files I can share them with you. I started with installing the full optware development package optware-devel. This takes about 250MB of storage in your /opt area. I got an error half way through when a new version of wget got installed (wget-ssl). The new wget requires the library libidn which is not present and for some reason not automatically loaded as a dependency. Since wget is used by ipkg to do the downloading, the install of optware-devel grinds to a halt. Now what? I simply renamed /opt/bin/wget and resorted to the true and trusted /usr/bin/wget of busybox. Restarting the optware-devel caused it to run to completion without anymore hickups. (To be able to use /opt/bin/wget I installed libidn also.)
Now we have a complete C/C++ software development system ready on the Pogoplug. We have make and compilers, a linker, a library archiver, etc.
sshfs needs libfuse, so let’s first build that.
I downloaded the fuse-2.8.5.tar.gz source code and did the following:
(Google where you can find it and use wget to download.)
# mkdir /opt/src
# mv fuse-2.8.5.tar.gz /opt/src
# cd /opt/src
# tar xvzf fuse-2.8.5.tar.gz
# cd fuse-2.8.5
# ./configure —prefix=/opt
# make
# mount -o rw,remount /
# make install
# mount -o ro,remount /
fuse wants to install some files in the usually read-only root file system, hence the remounts.
sshfs also needs glib. Let’s install it:
# ipkg install glib
I downloaded the source package sshfs-fuse-2.2.tar.gz and build that in the same way as fuse:
# mv sshfs-fuse-2.2.tar.gz /opt/src
# cd /opt/src
# tar xvzf sshfs-fuse-2.2.tar.gz
# cd sshfs-fuse-2.2
# ./configure —prefix=/opt
# make
# make install
And that’s all. Type sshfs and see if it runs. It should do this:
# sshfs
missing host
see `sshfs -h’ for usage
If you have man installed, you can read the manual page with man sshfs. Now for the ultimate test. Make sure you have a host machine that runs a sshd daemon and also has sftp-server installed (standard on most Linux distros). Assume that host has ip address 192.168.1.5 and has hostname nslu2 and that your account has name geert and password “password”. First create a mountpoint on the Pogoplug, for instance:
# cd /tmp
# mkdir nslu2
To mount your home directory on the nslu2 you would do:
# sshfs geert@192.168.1.5: nslu2
geert@192.168.1.5’s password: password
# cd nslu2
# ls
The last ls should now show you all your files in your home directory on nslu2. To unmount, use the command:
# fusermount -u /tmp/nslu2
I have bundled up all necessary binary files using the command:
tar cvzf /tmp/sshfs-2.2-pogo.tar.gz \
/opt/bin/sshfs \
/opt/share/man/man1/sshfs.1 \
/opt/bin/fusermount \
/opt/lib/libfuse.so.2.8.5 \
/opt/lib/libfuse.so.2 \
/opt/lib/libfuse.so \
/opt/lib/libgthread-2.0.so.0.2000.4 \
/opt/lib/libgthread-2.0.so.0 \
/opt/lib/libgthread-2.0.so \
/opt/lib/libglib-2.0.so.0.2000.4 \
/opt/lib/libglib-2.0.so.0 \
/opt/lib/libglib-2.0.so
You can find the tar file here
Power supply trouble
I am so happy with my Pogoplug that I bought a second one. After powering up I noticed a faint “electronics” smell, as if some plastic was getting hot. Still the device felt mildly warm to the touch and it was working properly. Putting my ear close to the plug I heard a faint buzzing sound, but only when a 2.5” USB external disk was attached. Clearly drawing some current (>500mA) had some effect on the power supply.
This lasted until one evening when it simply went dead: no lights, no whirring attached USB disk. Darn! Luckily I had experience opening up the plug and separating the power supply. A visual inspection showed no signs of burn. Wiggling some of the components I noticed that one of the 2 big capacitors was a bit loose; indeed one of its leads was no longer soldered to the underside of the board. I scratched some of the “paint” of the board to reveal copper and applied some solder to the lead. That was all. The power supply is back up again and this time it’s not making any noises and I believe the smell has receded as well.
Our compiled modules for PogoPlug V2.
Network file systems: SMB (Samba) and NFS
In the Windows world SMB network file sharing is king. Linux users are more familiar with NFS. There are two sides to sharing: a server side and a client side. The client software is usually easier to set up and use; the server typically needs some configuration.
On the pogoplug, an NFS client is build into the kernel. This means that you can mount any NFS share on your network as if it were a local directory on the Pogoplug. Just create a mountpoint (which can be any directory) and issue the proper mount command. For instance, create the mountpoint /tmp/nfs and let’s assume there is an NFS server on your local network with IP address 192.168.0.253 that exports the share called “/share/hdd/data”. The mount command then would be:
# mount -t nfs -o hard,udp,nolock 192.168.0.253:/share/hdd/data /tmp/nfs
Note that the -t nfs option is actually optional; the mount command knows how to figure this out by itself.
In a similar way it is possible to mount (or map in Windows speak) an SMB share on the Pogoplug. But for that you need the cifs.ko kernel module. In an other blog I will show you how to build that yourself. Also, we will make the extra modules available on the web download site. Assume you had the kernel module, the following commands would establish a mount:
# modprobe cifs
# mkdir /tmp/mnt
# mount //<your SMB server IP address>/<share> username=user /tmp/mnt
What is more interesting for most people is to be able you use the Pogoplug as a local file server without having to use the special Pogoplug driver software or having to interact via the web interface. Since the plug is there and holds a lot of your files, you’d like to have access to it in the usual way: map the Pogoplug disk on your Windows (or Linux) )laptop or desktop. You would need to install a local SMB server. Well, the samba35 package is just that. Get it through “ipkg install samba35”. You won’t just get samba but a load of other packages because of supposed dependencies. To be precise, you will get avahi, expat, libdaemon, dbus, adduser, popt, openldap-libs, libdb,
gdbm, and cyrus-sasl-libs. I doubt if all are really necessary.
Anyway, the samba server likes to run as user nobody. So we have to add that to /etc/passwd and /etc/group. It might also be useful to add a regular user (you for instance, or “geert” for me) so as not always have to login as root. I also believe that setting up samba users with the smbpasswd program looks in /etc/passwd first. My /etc/passwd looks like:
root:x:0:0:root:/root:/bin/bash
avahi:x:70:70::/:/bin/false
netdev:x:80:80::/:/bin/false
messagebus:x:81:81:System message bus:/:/bin/false
nobody:x:99:99:Nobody:/:/bin/false
geert:x:8786:5996:geert:/home/geert:/bin/bash
and my /etc/group reads:
root:x:0:root
avahi:x:70:
netdev:x:80:
messagebus:x:81:
nobody:x:91:
geert:x:5996:geert
As always use mount -o rw,remount / to edit those files. Where is my password? Well, in /etc/shadow of course. I put it there myself after first generating one with the “passwd geert” command. That puts a password in /etc/passwd which I then replaced by “x” and transferred to the /etc/shadow file. You can test things easily by logging in via ssh or telnet (start the telnetd on the Pogoplug first). If you password gets accepted, you are good to go.
Note that I added several other users and groups. These are required by dbus and avahi. If you intend to use those programs.
The samba server (the programs smbd and nmbd in /opt/sbin) are started from the script /opt/etc/init.d/S08samba, which itself is called with argument “start” from /opt/etc/init, the program that is part of the initial Openpogo set up. Nothing to do for you here. You might however decide to switch off dbus. Simply set ENABLED in /opt/etc/default/dbus to 0. When I first started the samba server (by hand, with “./S08samba start”) it complained about not finding a /opt/etc/printcap file. I created one and left it empty. What you really need is a version 3 /opt/etc/samba/smb.conf file. Do a google search and I am sure you’ll find one. Or use the following bare bones one:
[global]
workgroup = mygroup
server string = Samba Server Version %v on Pogoplug
security = user
load printers = no
cups options = raw
username map = /opt/etc/samba/smbusers
printcap name = /opt/etc/printcap
[pogoplug]
path = /
writeable = no
browseable = yes
guest ok = no
I created two samba users: root and geert using smbpasswd -a.
The man pages come with the package, so if you also “ipkg install man”, you can read them with “man smbpasswd”.
With the users set up and samba configured, you can run the server with “./S08samba start”. You should see 2 new processes in the ps output:
745 root 7764 S /opt/sbin/nmbd -D
747 root 14336 S /opt/sbin/smbd -D
Try mapping the Pogoplug pogoplug share from a Windows machine, using the user name that you chose with smbpasswd -a <user>. From Linux you can use Nautilus to connect via the smb://<server>/<user> service or use the sbmclient program or create a samba mount. Have fun.
Final note: I created a /home symbolic link that points to a disk partition where I keep user’s home directories.
I love Emacs
I use Emacs for all my programming and text-editing since 1981. No other editor comes close to its capabilities. Having to use anything but Emacs always makes me feel uncomfortable to say the least. On most of my embedded linux devices I have to resort to jove or mg or qemacs or such, simply because for a lack of resources mostly memory and cpu speed. But the Pogoplug is fast and has plenty of RAM. Therefore I chose to do an “ipkg install emacs22” using the packages repository at http://openpogo.com/repo.
It works very well except for one snag: dired mode does not function. And this is very important to me because I’d like to browse the file system within Emacs. Ask any midnight commander user and he/she will acknowledge how important that feature is. Turns out that on the plug, /bin/ls, from busybox of course, is not up to par and doesn’t support the —version argument that dired relies upon. There are many ways to fix this. I opted for a better ls. You can find it in the coreutils package. Download it with “ipkg download coreutils_8.4-1_arm.ipk”. Knowing that .ipk packages are really just tar.gz files helps. Once unpacked, extract the ls program from data.tar.gz as follows: “tar xvzf data.tar.gz /opt/bin/coreutils-ls”. Make sure it is excutable with “chmod 755 /opt/bin/coreutils-ls”. The last step is to make emacs aware of the new ls. For this create a .emacs file in /root (emacs /root/.emacs) with the line (setq insert-directory-program “/opt/bin/coreutils-ls”). Don’t forget to enable writing on the / file system (remember mount -o rw,remount /) and make it read-only again afterwards.
One more thing, typing ls in a shell within Emacs will issue special escape codes to color the file names. Turn this off by using ls —color=never.
A discovery
Did you know that hidden within the published source code of the Pogoplug’s linux kernel resides a “binaries” directory with a bunch of .tgz files in them? Get it from http://download.pogoplug.com/opensource/pogoplug-linux-2.6.22.18.tar.bz2 (65.6MB). Put it on a linux host (you can even use the Pogoplug itself) and bunzip and untar. By the way, the GNU/gcc cross compilers are at that URL too. Check out: http://download.pogoplug.com/opensource/pogoplug-gcc.tar.bz2 (74.7MB).
Back to the kernel source. Look in that binaries directory and open e.g. 88f6281.tgz. You will find that to contain a kernel and lots of kernel modules. Those modules actually work with the current kernel running on the Pogoplug. So by moving those modules over to the plug and using the insmod command you can now attach a USB CDROM/DVD device and mount that. A nice way of using new kernel modules is to put them in /lib/modules/2.6.22.18. You will have to create that directory first. Mind to make / writable with mount -o rw,remount /.
Since you are at it, create also a modules.dep file there with a line for each module. For instance it could look like this:
/lib/modules/2.6.22.18/cdrom.ko:
/lib/modules/2.6.22.18/cifs.ko:
/lib/modules/2.6.22.18/isofs.ko:
/lib/modules/2.6.22.18/loop.ko:
/lib/modules/2.6.22.18/sr_mod.ko:
/lib/modules/2.6.22.18/udf.ko:
/lib/modules/2.6.22.18/usbserial.ko:
With this in place, you now can use modprobe cdrom to load the cdrom.ko kernel module. Pretty neat.
Here is the link to the kernel modules and the modules.dep files:
downloads
Yet another Openpogo blog…
We like to use this blog as a place to vent our experience with the Pogoplug, in particular we talk about the Pink one being the V2 model. There are lots of related blogs and websites dedicated to this nifty little device. Our main goal for now is to provide simple additions and modifications to the software while retaining its original functionality. We think my.pogoplug.com is a great asset and we don’t want to lose it.
So far we have performed the usual “Openpogo” modifications: we are able to ssh into the device and we have added a /opt that maps to a partition with a .opt directory. Then that .opt was populated with the ipkg package manager. We will describe what we installed on the system and what configurations were needed.