Copy Files to Pogoplug Without The Pogo Software (using scp)

I recently picked up a Pogoplug on sale from John Lewis and thought I’d give it a whirl with my media.

Although it is a neat little device, one of it’s biggest benefits is also it’s biggest flaw in terms of design – and that is how it requires you to sign into pogoplug.com and maintain an account there. It also requires you to mount the pogoplug with their software for transferring and viewing files, rather than acting as a NAS.

Whilst it’s nice to have easy access to media outside of home (without having to fiddle with setting up port forwarding on your firewall and whatnot) it’s a bit of a drag when you’re on your own network. I noticed a severe performance¬†degradation¬†copying media to my pogoplug device using pogoplugfs rather than through a standard means. So I learned that Pogoplug does appear to have a Busybox install and along with that SSH access. In order to enable SSH access, Cloud Engines have been gracious enough to allow this through your my.pogoplug.com portal. You simply go to Security options and enable SSH, and change the password. From there it’s just a simple,

ssh root@<pogoplugIpAddress>

The problem is that there doesn’t seem to be any support for sftp and therefore I couldn’t use ssh in a file manager. Thankfully however ssh provides scp protocol and from there it was just as short script in order to zap files across over local lan without worrying about signing in.

When you attach an external harddrive to the Pogoplug, your files will be installed in a directory similar to ‘/tmp/.cemnt/mnt_sda2/’ where ‘mnt_sda2’ will be the mount point of your media device.

Be aware this script utilises “expect”, but you could use private keys instead.

ppsend.sh:
#!/bin/bash
#set -x
# Provide a list of media extensions to send to pogoplug
extensions=("mp4" "avi" "mkv" "jpg");
ppip="192.168.1.10" # The local ip address of your pogoplug
echo ""
echo "Sending video files to PogoPlug ($ppip) for the following extensions..."
for ext in "${extensions[@]}"; do
echo ${ext}
done
echo ""
for ext in "${extensions[@]}"; do
 expect -c "spawn bash -c \"scp -p *.$ext root@$ppip:/tmp/.cemnt/mnt_sda2/\"
 expect assword ; send \"mysshpassword\r\"; interact"
done

I think the next step for this is to translate it to another language and wrap it up in a GUI for easy access. So watch this space perhaps.

Headless Recovery with Persistent Ubuntu Live USB

As some of you know, recently my Samsung NC10 netbook screen was smashed in an unfortunate accident. I have since replaced this with the excellent Sammy N210 but was at a loss where to begin recovering data from the NC10.

Of course, the obvious solution was unscrew and take out the hard drive, however these Netbooks are tightly built, and since I’m still considering the possibility of replacing the screen, I don’t want to create any superficial damage to the case.

So I googled for options, initially hoping to snag a Linux liveCD that would automatically boot with sshd in order for me to log in remotely.

Aside from some vague forum references to Knoppix and editing configuration files, I got nowhere. However what did occur to me was that Ubuntu LiveCD on a usb flash drive can be set to be persistent so it saves any changes including packages and settings.

The following steps are what I did to get access to my netbook data despite having a smashed screen, without needing to take out the hard drive, hook up an external monitor or building my own distro. Hopefully it may be useful for anyone finding themselves in a similar situation.

This is by no means a silver bullet. You will require the following setup for this to work:

  • The system with the broken screen must be capable of booting from USB.
  • The Bios must already be set to boot from USB (unless you have some way to set it without a screen).
  • A second ‘puter with sshd installed and running.

This will not work with a LiveCD, it needs to be a USB pen drive so that changes can be easily saved on the drive.

  1. Download an ISO of Ubuntu or Netbook Remix, which is what I used, and then use the Startup Disk Creator to create a live USB pen drive – check the box for persistent mode (“Stored in reserved extra space”).
  2. Run the LiveUSB and when it boots to desktop open a terminal and type:

    sudo apt-get update
    sudo apt-get install openssh-server

  3. When installing openssh on a LiveCD/USB you need a password to log in remotely. This can be done 1 of 2 ways, either by setting ‘passwd’ for the default ubuntu user or creating a new user. NerdNotes.org offers a nice and easy tutorial. In practice I found that when I rebooted the liveUSB for some reason the default ubuntu user ‘lost’ the password so I had to create a new user instead.
  4. If you have created a new user, be sure to add the username to the admin group, giving root privileges:
  5. sudo adduser <username> admin

  6. Test the ssh daemon by logging in remotely to the machine you will use for recovery. If you are prompted for a key then type ‘yes’ and hit enter:
  7. ssh username@hostname

  8. Then make sure you can ssh back to your ubuntu LiveUSB. You may also want to do a quick reboot and test run to see if you can ssh without problems and without touching the LiveUSB keyboard.
  9. Now shutdown the LiveUSB and plug it into your headless netbook/laptop, switch it on and let it boot up, it should take about 30 seconds to boot automatically after the menu and then another 30-45 seconds before you can ssh in.
  10. Create a directory you are going to use to copy all your files from your netbook.
  11. wafitz@ $ mkdir /media/bkup

  12. Once you can ssh to the LiveUSB, you want to mount your hard disk partition.
  13. wafitz@ubuntu$ sudo fdisk -l

    Device Boot      Start         End      Blocks   Id  System
    /dev/sda1               1         182    160101883+  82  Linux swap / Solaris
    /dev/sda2   *       53782       60802    69389632    7  HPFS/NTFS

    wafitz@ubuntu$ sudo mount /dev/sda1 /mnt

  14. It should now be easy after this to grab your files and scp them back to your curent system, whether you previously had Windows or Ubuntu (or other distro) Linux installed. However if like me, you had an encrypted home partition, then keep following the steps:
    I got the original instructions for this from Dustin Kirklands blog – nb: I needed to use ecryptfs-add-passphrase in order to record my passphrase manually before mounting the encrypted directory.
  15. wafitz@ubuntu$ sudo mount -o bind /dev /mnt/dev
    wafitz@ubuntu$ sudo mount -o bind /dev/shm /mnt/dev/shm
    wafitz@ubuntu$ sudo mount -o bind /proc /mnt/proc
    wafitz@ubuntu$ sudo mount -o bind /sys /mnt/sys
    wafitz@ubuntu$ sudo chroot /mnt
    root@ubuntu$ su - wafitz
    wafitz@ubuntu$ ecryptfs-add-passphrase --fnek
    wafitz@ubuntu$ ecryptfs-mount-private
    Enter your login passphrase:

    Warning: Using default salt value (undefined in ~/.ecryptfsrc)
    Inserted auth tok with sig [xxx] into the user session keyring

    wafitz@ubuntu$ cd $HOME
    wafitz@ubuntu$ ls -a

  16. Finally you can do a secure copy from your netbook back to your host pc:
  17. wafitz@ubuntu$ scp -pr * wafitz@:/media/bkup

If you have found this post whilst searching for a solution and this helps you, please let me know. Even more so, if this method can be refined or improved then I’d also like to read your comments!