Dropbear and Backup

Ok first quick post, here goes.

A few months ago I purchased a second hand Dlink DNS323 NAS

I wanted to set this up so that I could have a dedicated back up device, that previously I was using a laptop for.

the default firmware on the NAS  was not really up to the task so I googled for alternative firmware and found/installed Alt-F (an embedded Linux alternative to the native firmware),as it had both a SSH client/server (dropbear) and Rsync and other good stuff by way of it having a package manager “Alt-f”, (in fact there is also a second package manager called ffp )

As I mentioned before I was using a laptop to carry out the back ups using an alias to login via ssh (password-less key authorization) and to call rsync synchronize the content of one machine to the laptop, this was achieved through the use of OpenSSH and Rsync packages and looked something like this

rsync -avz -e ssh user@192.168.x.x:/home/user/source-folder ~/user/destination-folder/

The issue being that the NAS uses dropbear for ssh and uses ash for its shell, which makes it different enough to throw a challenge or two.
where as OpenSSH has a hard-wired location for keys (~/.ssh/id_rsa) dropbear requires you tell it where the id file is for the password-less authentication, this could be any location your user has access to..
Dropbear achieves this by having an “-i” switch as part of its ssh command (eg ssh -i /home/username/.ssh/id_rsa) which has to be incorporated into the command for the synchronization like so

rsync -avz -e 'ssh -i /home/username/.ssh/id_rsa' user@:192.168.x.x:/home/user/source-folder ~/user/destination-folder/

I realized very soon this is a pain to type out for every synchronization, but also knew that busybox’s Ash shell did not do .bashrc or .bash_aliases then I found the answer
Ash sources .profile when you log in, so you can add aliases there on machines running busybox/ash. you would set it up as follows

touch .profile
nano .profile

alias go-get="rsync -avz -e 'ssh -i /home/username/.ssh/id_rsa' user@:192.168.x.x:/home/user/source-folder ~/user/destination-folder/"

save, then log out and back in again to source the .profile

Now to do an incremental manual back up of the source device , all i need to do when logged into the destination machine is type “go-get” <enter> and rsync over ssh will take care of that for me.

Hope this is useful to someone, somewhere


Dropbear and Backup

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s