Out Here In The Field : Journeys


Public Key authentication for passwordless/unattended/batch SCP/SSH session
October 31, 2007, 3:32 pm
Filed under: *Nix, SCP

So one day, My superior gave me a task to create a process that transport data (in text file) from one nix box to another nix box. Since the target box has internet facing interface, public IP, and doesn’t have any firewall installed in any form whatsoever, it has to be over SSL. So it’s either sftp or scp. The file transport will be part of a batch process. So I choose SCP over SFTP, since it only require one line of command instead of a scripted process.

Since the process will be an unattended one, manually typing password is out of question, so I turned to public key authentication. Here are the steps:

1. Make sure the target SSH server accept public key authentication
As root, open sshd_config on the target server, usually located in /etc/ssh/sshd_config

sudo nano /etc/ssh/sshd_config

Make sure these lines are available and not commented

PubkeyAuthentication yes
AuthorizedKeysFile %h/.ssh/authorized_keys

2. Make sure the ssh client know where the private key is located
As root, open ssh_config on the client machine, usually located on /etc/ssh/ssh_config

sudo nano /etc/ssh/ssh_config

Make sure this line is available and not commented

IdentityFile ~/.ssh/identity
IdentityFile ~/.ssh/id_rsa
IdentityFile ~/.ssh/id_dsa

3. Create a pair of private and public keys
To do public key authentication, you need to have a pair of keys. Private key is stored on ssh client machine as your identification, and public key is stored on the target ssh server, used by sshd to authenticate you on ssh server.

Log into the ssh client machine with the account that you’ll be using to connect to target server, and issue this command:

ssh-keygen -t dsa

The output should be similiar to this

ikhsan@M5mobile:~/.ssh$ ssh-keygen -t dsa
Generating public/private dsa key pair.
Enter file in which to save the key (/home/ikhsan/.ssh/id_dsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/ikhsan/.ssh/id_dsa.
Your public key has been saved in /home/ikhsan/.ssh/id_dsa.pub.
The key fingerprint is:
be:4d:36:7c:29:a9:e0:8a:c0:c5:d5:65:40:fe:97:4b ikhsan@M5mobile

Since my requirement was passwordless authentication, I didn’t enter any passphrase. Note that the private (id_dsa) and public (id_dsa.pub) keys have been generated, and stored .ssh directory

ikhsan@M5mobile:~$ cd .ssh
ikhsan@M5mobile:~/.ssh$ ls
authorized_keys  id_dsa  id_dsa.pub  id_rsa  id_rsa.pub

4. Install the public key into the target ssh server
Copy the public key into target ssh server

ikhsan@M5mobile:~$ cd .ssh
ikhsan@M5mobile:~/.ssh$ scp id_dsa.pub surfer@M5base:/home/surfer/.ssh
surfer@M5base's password:
id_dsa.pub                                    100%  605     0.6KB/s   00:00

log into the ssh server as the user that will use the passwordless authentication, in my case, it’s “surfer”. Install the public key into the server by issuing this command:

surfer@M5base:~$ cd .ssh
surfer@M5base:~/.ssh$ cat id_dsa.pub >> authorized_keys

The above commands will add the public key into authorized_keys file. It is important to do add the key by using the above command so that any existing keys in the authorized_keys file are not overwritten.

update@10/0/2008

Sometime, the .ssh folder is not available, and you are required to create them manually. This may cause some problem regarding the access restriction of that folder. To create the folder, do the following:

surfer@M5base:~$ mkdir .ssh
surfer@M5base:~$ chmod -R 700 .ssh

Go here for more about the problem.

5. Test your connection
Try to log to the target ssh server, the output should be close to this:

ikhsan@M5mobile:~/.ssh$ ssh surfer@M5base
Linux M5base 2.6.20-15-generic #2 SMP Sun Apr 15 07:36:31 UTC 2007 i686
The programs included with the Ubuntu system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.
Ubuntu comes with ABSOLUTELY NO WARRANTY, to the extent permitted by
applicable law.
Last login: Wed Oct 31 21:57:19 2007 from localhost
surfer@M5base:~$

Now you can test your setup by copying file from ssh client machine to the ssh server:

ikhsan@M5mobile:~$ scp w3sp_BigPianoAlbum.rar  surfer@M5base:/home/surfer
w3sp_BigPianoAlbum.rar                        100%   33MB  11.2MB/s   00:03

… and you’re done

Update@10/06/08

If you created the .ssh folder manually, you might run into some problem where the public key authentication is bypassed due to the security level of the .ssh folder. Go here for the solution regarding this problem



PuTTY
October 30, 2007, 4:14 pm
Filed under: *Nix, Ubuntu

So one day, my friend borrowed my laptop (runs Feisty Fawn) because he need a couple of machines for testing. Then he asked me “This might sound stupid, but do you, by any chance, have PuTTY installed on your laptop?”

Well yes of course!!

PuTTY is available on Ubuntu repository, just type

sudo apt-get install putty



Supercard on Ubuntu
October 28, 2007, 2:30 pm
Filed under: *Nix, Go Go Gadget..Stuff!!, Nintendo DS, Ubuntu

I own a DS Lite. And just like any Indonesian that own a DS, I use it in conjunction with SuperCard. Mine is the SC Lite MicroSD version. SuperCard seems to score less favourable than it’s competitor, due to it’s horrendous compatibility with GBA games, and the lack of features compared to other product. But it seems that most Game Shops in Jakarta only sell SuperCard since I believe it’s far cheaper that it’s competitor.

Anyway..

I made my transition to Linux on my notebook, a couple of months a go, as soon as I received my copy of Feisty Fawn. I boot mostly to Linux now, still have Windows (Vista) installation, but it’s only used for iTunes.

..and SuperCard!

I googled around, and the only viable solution to run SuperCard software on Linux seems to be to run it under Wine.

So, in order to do that, first install Wine if you haven’t already done so.

sudo apt-get update
sudo apt-get install wine

Download the latest version of SuperCard software. The latest release seems to be v2.62, as the newer 2.63 is still in beta.

After the download is finished, unpack the the archive

unzip setupmicrosdV262en.zip

It’ll create a folder “setupmicrosdV262en”. Inside the folder are readme.txt, written in magnificent engrish, “micro_eng_183.bin”, the newest firmware for SuperCar MicroSD, and the installer for the converter “setupmicrosdV262en.exe”
Run the installer by either doubleclicking it, or via terminal

wine setupmicrosdV262en.exe

The installer will run as if it’s on Windows, so you know what you have to do.

scinstall.jpg

Press every instance of the “next” button that appear, and finally press finish. You can start SuperCard by going to Applications>Wine>Programs>Super Card>Super Card. Let’s run it.

sc4.jpg

Everything seem to be in working order until..

sc7.jpg

Apparently the completion confirmation dialog was drawn under the main Super Card software windows, and I don’t seems to be able to toggle to it. More over, the SuperCard software did not appear on my Windows List. Even worst I can’t kill the session, and even the log out dialog on Gnome failed to work.

So I switched to Terminal, and killed my Gnome-Session.

Let’s try again. This time, before starting the convert process, i moved the main SC Windows a bit lower, and pressed the “out” button… and voila!

sc6.jpg

The completion confirmation window appear at the top of the main window. Click the OK button, and the convertion process is finished.

What I like about SuperCard is, even after releasing the newer version of SuperCard (the DSOne, used on DS slot-1), they continue to support the older version of their product. New to the SC Lite is the ability to use cheat codes (GameShark, Action Replay), even though it’s a little complex to use. But I like the spirit. The process require you to manually convert a .cht file to SuperCard native cheat files (.scc) using small software provided by SC maker. I haven’t got the time to try it on my Feisty, but be sure to check back.



SMC Pentax-DA 40mm F2.8 Limited
October 28, 2007, 2:08 am
Filed under: Go Go Gadget..Stuff!!, K100D, Pentax, Photography

My second (the first being a secondhand SMC P-M 50mm F1.4 manual lens, I’ll talk about it later) prime lens is a pentax “pancake” lens, the SMC P-DA 40mm F2.8 Limited.

40mm.jpg

Just like any other pancake lens, the size is very minuscule compared to the “standard” sized lenses. Here is the DA 40mm F2.8 standing side by side with my Tamron AF70-300mm F4-5.6 Di LD and Pentax SMC P-DA 18-55mm

comparisontb1.jpg

It came packaged with a nifty pouch to store the lens when it’s not mounted on your camera.

pouchtb.jpg

Test shot on Revoltech Black Getter Robo, resized, and photoshopped to remove the stand, otherwise nothing was altered. Click to view larger size.

bgetter1tb.jpg

This one is a pic of my neighbour’s kid

Combined with K100D’s SR function, the DA 40mm Limited is suitable for indoor photos, although isn’t quite as good as the M 50mm F1.4. And for a Limited lens, the price is not that expensive.

All photos beside the test shot is taken with Canon Powershot A640.



Picasa 2
October 27, 2007, 11:30 pm
Filed under: *Nix, Photography, Ubuntu

There are Picasa 2 installers available for Linux (.bin, .rpm, .deb). Apparently it uses Wine to run. I already have Wine installed on my laptop for other purposes, so instead of using them, I opted to install the Ms Windows version of Picasa2 on my Feisty. Beside the download size is far smaller than all of the Linux installer (since they are bundled with Wine).

If you haven’t installed Wine, you need to

sudo apt-get update

sudo apt-get install wine

Download the latest Windows version of picasa here, and double click the downloaded file to install Picasa. Picasa can be found on Applications>Wine>Programs>Picasa2.

picasa.png

There is downside to this method. It will recognize your folder trees just the way any application that runs under Wine. Means, It’ll recognize your home and desktop just fine, and slightly confuse you on other mounted partitions(driver letters instead of names) and root (“/”) folder. All function seems to be working as it should be. I am able to import and export photos from folders and external storage/devices, all image manipulation functions are working, and the upload function works fine too.

.. Oh and please visit my picasa page



GDesklets
October 27, 2007, 11:08 pm
Filed under: *Nix, Ubuntu

Anyone who have tried Windows Vista should be familiar with Windows gadget on the sidebar. How do we do it in Ubuntu you say?

use gdesklets.

First, open a terminal, and update your apt-get database

sudo apt-get update

And then, install gdesklets

sudo apt-get install gdesklets

After it finished installing, start gdesklets

gdekslets

Gdesklets icon should appear on your notification area, right click on it, and click on Manage desklets.

screenshot-gdesklets-shell-1.png

Add as many desklets as you want, my fave is the starterbar from Toolbar/Launcher, and it currently replaces my bottom gpanel as application shortcuts holder.

screenshot-gdesklets-daemon.png

…Anyway..

Make sure that Gdesklets is started everytime you log into your desktop by going to System>Preferences>Sessions. On Startup Programs tab, click on New, and input “gdesklets” into name and command columns. Make sure it is ticked.

…And you’re done



Out Here in The Field..
October 27, 2007, 10:29 pm
Filed under: IRL

..for now is hosted on http://outhereinthefield.wordpress.com. Maybe for good.. who knows?