‘ Open Source ’ Category

Sabri – Ssh from Automatic Bash Remote Inditement

Comments // Written on Jul 02, 2009 // Open Source

SabriI got a memory leak problem on my brain. Can’t remember all the passwords, hosts and usernames to connect to work and home servers, remote hosts etc. Usually I store everything on gnote and then simply copy&paste on my terminal, but I got bored about that, so I created sabri.

Sabri ( Ssh from Automatic Bash Remote Inditement ) is a Bash script able to store on a sqlite3 database all my ssh connections data (host, user & pass) and then connect to any of them automatically without prompting me for each password. I used Expect for automatic password send to openssh server and Crypt::Tea perl module to encrypt passwords for data safety.

Here’s how it works:

sabri -i #Installs the Database and create tables
sabri -s # Create a new connection
sabri -d connection_name # Connects to a stored connection

Easy uh?

Sabri is still in pre-release, I still didn’t realize any error detection/prevention, but if anyone wants to try it out just clone my sabri’s git repository

git clone git://github.com/andreaolivato/Sabri.git

or go to GitHub to download the zip file.

Please run

sabri -h

and

sabri -c

before any other action!

Google Chrome natively running on Gentoo Linux

Comments // Written on Jun 05, 2009 // Open Source

This is just a quick & (very) dirty trick to run Google Chrome on Gentoo Linux using a precompiled debian package instead of compiling the enormous source tarball.

Step 1. Download the Deb

Get your browser to Developer Download page for Linux x86 and accept Google Terms of service.

Step 2. Unpack the unpackable

Open a terminal emulator and cd to your download directory ( mine is Desktop )

cd ~/Desktop
mv google-chrome-unstable_current_i386.deb /tmp
cd /tmp
ar x google-chrome-unstable_current_i386.deb
tar xvf data.tar.gz
sudo cp opt/google/chrome /opt/ -r
sudo ln -s /google/chrome/chrome /usr/bin/

Step 3. Link some libs

Chrome requires some libs which I didn’t find in my gentoo portage tree. Probably I could update nss and nspr but I prefer using stable ebuilds so I decided to manually link some missing libs…

ln -s /usr/lib/nss/libnss3.so.12 /usr/lib/libnss3.so.1d
ln -s /usr/lib/nss/libnssutil3.so.12 /usr/lib/libnssutil3.so.1d
ln -s /usr/lib/nss/libsmime3.so.12 /usr/lib/libsmime3.so.1d
ln -s /usr/lib/nss/libssl3.so.12 /usr/lib/libssl3.so.1d
ln -s /usr/lib/nspr/libplds4.so.7 /usr/lib/libplds4.so.0d
ln -s /usr/lib/nspr/libplc4.so.7 /usr/lib/libplc4.so.0d
ln -s /usr/lib/nspr/libnspr4.so.7 /usr/lib/libnspr4.so.0d

Step 4. Run it

If you want to simply launch it you just need to run chrome from anywhere.
If you want to create a launcher you can use chrome as command and choose an icon from /opt/chrome/

This is just a pre-release and many features are missing. Anyway I’m quite happy about having the possibility to try out Google Chrome without compiling it (it would be a cpu suicide I believe) and I noticed that it seems incredibly fast on launching. Maybe it’s because not all features have been built in, but it’s impressive in any case!

Here’s a screen I made from my Gentoo Box

Google chrome on Gentoo

HTC tytn II sharing Wireless via USB with ancient linux Laptop

Comments // Written on May 06, 2009 // Open Source

I own a very old IBM laptop, 64 MB of memory 533Mhz Intel celeron 5Gb HD, running ubuntu 9.04 alternate with fluxbox and custom kernel. Unfortunately this laptop doesn’t have any way to connect to internet but the old 56K modem. The pcmci port seems broken (also I don’t think spending 50€ for a pcmcia wireless or eth card is a good idea as the laptop value is around 5€) so the latest chance for me to navigate from this old friend is connecting something to the USB…

Instead of buying some usb key or similars (see reasons above) I decided to try configuring my HTC tytn II (Kaiser) running Windows Mobile (WM6) as USB gateway for the laptop. Here’s what I did after googling a bit.

Config the laptop

I found this interesting thread showing how to install usb connection module. As I could nor install svn neither download the trunk from the laptop I did the checkout from my gentoo desktop

svn co https://synce.svn.sourceforge.net/svnroot/synce/trunk/usb-rndis-lite

and then copied the trunk to an usb pen and transferred it to the laptop. Inside the laptop I configured, compiled and installed the module.

make
sudo ./clean.sh
sudo make install

Then I added the connection to my interfaces

sudo vim /etc/network/interfaces

with this configuration

iface rndis0 inet dhcp
auto rndis0

Config the Phone to share 3g

If you want to share your 3g connection just open your comm manager and select share connection or similar. In the next screen just choose the operator/type of connection you want to share (3g,hdspa,edge ecc) and the usb as vector. Plug the phone to the usb cable, the cable to the pc and skip to Start the networking

Config the Phone to share wireless

As I don’t own a flat plan for mobile connection I’d rather prefer sharing my home/work wireless trought the phone. To do so I found this great tool for Windows Mobile named ICS commander. Just download the .exe and run it from your mobile (no it’s not a cab installer, just a binary to exec). I configured it this way for my kaiser:

  • Public Interface : TNETW12511 (this means I want to share my WIFI)
  • Private Interface : RNDISFN1 (this means I want to share it via USB)
  • Check ‘Set Private IP’ and set it to 169.254.2.1 (this is kaiser default own ip)
  • Check ‘Auto Connect to Network’ with ISP settings
  • Uncheck ‘Allow suspend Mode’ (this prevent your phone to cut wifi and go in standby )
  • Be sure DHCP server is checked

Now just select ‘Save‘ and then ‘Start ICS‘. Plug the usb cable, and plug it to the laptop.

Proceed with Start the networking.

Start the networking

Back to the laptop.

sudo /etc/init.d/networking restart

You’re done, you should see your IP and then you can ping the world

ping google.com

Sync Epiphany bookmarks with Unison and Dropbox

Comments // Written on Apr 20, 2009 // Net, Open Source

Yes, since I was able to run Dropbox on Fluxbox I’m quite exhausting it, trying to sync most of my work settings with my home computer.

As I prefer using Epiphany to Firefox, I needed to find a way to easily sync my bookmarks but unfortunately the symbolic link made from epiphany folder to the Dropbox one didn’t work as expected, and I didn’t want to use Epilicious ( -> Magnolia) to store all my bookmarks.

So I tried with Rsync but the result was not so good, as it’s not natively bidirectional. Unison, instead, worked exactly as I wanted to!

mkdir ~/Dropbox/epiphany
unison ~/.gnome2/epiphany/ ~/Dropbox/epiphany/ -path ephy-bookmarks.xml -terse -auto -silent -ui text

Unison will sync the two files, merging them or giving output about conflicts (if you modified the file on both computers and it’s not able to merge them, like svn does). Also note that while usually unison works with directories I imposed to sync just the ephy-bookmarks.xml file, using the -path option.

As the file is not that big and it’s not modified so often I put the command on the crontab every 2 minutes. You should choose a period that fits your pc load/activity…

crontab -e
*/2 * * * * unison ~/.gnome2/epiphany/ ~/Dropbox/epiphany/ -path ephy-bookmarks.xml -terse -auto -silent -ui text

I think this can be useful to sync even other services/preferences…

Harden dropbox using safe encfs encryption

Comments // Written on Apr 16, 2009 // Net, Open Source

While continuing to share datas beetween my two workstations using Dropbox, I started getting worried about data safety. Looking at DropBox wiki I found this interesting page in which I highlighted  the part that attracted me.

DropBox guys are suggesting to use a simple file-per-file encryption very easy to achieve in any Linux environment thanks to encfs. I tried this method beetween my two Gentoo boxes and I’m very satisfied: it works like a charm, being terribly easy to set up.

Here’s what I did :

sudo emerge sys-fs/encfs
mkdir ~/Dropbox/Safe
mkdir ~/Safe
encfs ~/Dropbox/Safe/ ~/Safe

Encfs prompted me for an installtion method and I choose the automatic one (it set up default protection levels and methods without my unable interaction) then for a password. After setting up the password everything was ready to be used. I started putting my files into the Safe folder in my home and saw the corresponding encrypted files on Dropbox/Safe.

When I got home from work i installed the same ebuild, created the same dirs and typed for the same pass to encfs…Dropbox updated the encrypted folder and encfs did the rest…

I also set up my tomboy notes to be synced into the encrypted folder instead of the common one so that I now can share sensible notes without too many worries!

Easy, fast and seems quite safe to me…

Sync Skype chronologies using Dropbox

Comments // Written on Apr 15, 2009 // Net, Open Source

I use Skype both from work and home with the same account and a lot of times I received some links at work and forgot to save them on tomboy or send it by mail, so when I got home I could not find them.

Today I found a simple but rough solution to share my Skype chronology beetween my two computers, using the wonderful Dropbox service. First of all I found my skype setting and cache folder, which in GNU Linux is located on the userhome, under the hidden .Skype folder. Inside .Skype, there are some folders, named as the account you used on that computer and some config files. What I did is simply to move the folder of the account I wanted to share the chronology for inside the Dropbox folder and then symlink it on its previous location. So after closing Skype from terminal it was just a matter of

cp ~/.Skype/account_name ~/Dropbox/
ln -s ~/Dropbox/account_name ~/.Skype/

Then I logged in the othe pc via SSH and did the same symlink without copying the folder into Dropbox. This means that in the second pc I would have just the chronology of the first one and not the previous saved history. Maybe there’s a better way to do so, merging the two chronologies before sharing and sobstituting one to the other, but I didn’t care so I just overwrote my house Skype history (after a quick backup) doing

cp ~/.Skype/account_name ~/skype-account_name_bk
ln -s ~/Dropbox/account_name ~/.Skype/

The trick is done. Obviously mantaining two opened skype session on the two computers might generate errors. Also I noticed it’s quite expansive for the net as Dropbox tries to update every chronology file that skype modifies so every time you chat or receive any message it syncs some files, doubling the traffic. Anyway I reached my target and confirmed that Dropbox is terribly useful…

Pulseaudio Applet on Gnome Panel

Comments // Written on Apr 07, 2009 // Open Source

During the last few days I enjoyed myself destroying my gentoo gnome installation upgrading from 2.24 to newer 2.26 which is not included in default portage. I installed it from gnome overlay and as I was resolving dependancies and compiling a lot I decided to enable support for pulseaudio. I added the use flag to my make.conf and then emerged necessary packages.

As I’m not a multimedia man, I can’t really understand how and when pulseaudio has a better rending then other systems, however I really appreciate the possibility of setting each application volume, feature that I was missing before.

The only thing I still needed and that I did not find on the overlay was an applet to replace the deprecated gnome-volume-control. So I googled a bit and found gnome-pulse-applet project on google code.

Installation is very easy. It’s just a matter of

wget http://gnome-pulse-applet.googlecode.com/files/gnome-pulse-applet-0.2.tar.gz
tar xvf gnome-pulse-applet-0.2.tar.gz
cd gnome-pulse-applet-0.2
make
sudo make install

After compiling it, I had to restart my gnome environment as just killing and restarting the panel gave me some python errors.

Result is very nice, the applet is minimal and useful, it got some preferences in which you can choose the direction of the applet and the default output source. I really suggest every one using Pulseaudio to use this applet…

vertical applet 150x150 Pulseaudio Applet on Gnome Panel horizontal applet 150x150 Pulseaudio Applet on Gnome Panel

Automatically fade background with Canvas and javascript

Comments // Written on Mar 26, 2009 // Net, Open Source

Using complex background images for div elements is very useful to create nice effects on web pages. Most of the images used as BG have a central pattern and then a gradient which ends at the image borders. If you use one of these image as background of a div you need to make them of the same size of the div (or bigger) so that it is able to cover the whole space with the gradient. Doing this means manually manipulating an image, increasing and decreaing its width/height.

I created a JS library that provides a simple way to avoid image manipulation, using Javascript to retrieve colors informations about the latest pixels of the image and to repeat that pattern until the end of the div. You don’t need to open any graphic program, you don’t need to add other divs, just include the script and it will do the dirty job for you.

If you’re interested on how this script works and what you could achieve by using it, you can retrieve more informations on the project page. Also take a look at the labs page, where you can see the script in action.

Running apache2 virtualhost with different users

Comments // Written on Mar 21, 2009 // Net, Open Source

On my dedicated server (running Debian Lenny) I run different websites and some of them are managed by other people. This means I had to give those people access via ftp and/or ssh to my box. As most of those sites use cms to manage content, they usually need the user which is running the webserver to be able to write their domain folders too.

In the past I managed to make folders writable both from the webserver and the user, adding every user I created for ftp/ssh access to the www-data group and then giving directories 664 permission. This way both the webserver and the user were able to write but I was not satisfied with this solution.

I knew that it was possible to wrap everything with SuExec and Cgi but I preferred running php forked by apache without CGI so this solution didn’t fit my needs.

I recently came to know the wonderful apache2-mpm-itk module. By enabling this, it is possible to achieve a true multiuser apache2 installation without wrapping anything to SuExec. Following some easy steps you would be able to specify an user+group for each virtualhost you run.

On Debian installation is quite easy as the apache2-mpm-itk module is on the repo. Note that installing it would remove common apache2 installation and the apache2-mpm-prefork as the module is compiled inside apache2. So to install it just

$ sudo apt-get install apache2-mpm-itk

As the module is built in you do not need to a2enmod anything. Just go straight on your virtualhosts folder ( /etc/apache2/sites-available ) and enable it by adding this line for each virtualhost.

<IfModule mpm_itk_module>
AssignUserId USER GROUP
</IfModule>

If you do not specify any user for some virtualhost they are going to run with default apache2 user (www-data, apache2, httpd or the one you specified on the configuration file).

Now, before reloading apache2 configuration be sure to reset permissions on your virtualhost, changing them from www-data to the new user:group using chown and if needed chmod. I usually do this

$ sudo chown USER:GROUP /var/www/some-virtualhost/ -R
$ sudo chmod 644 /var/www/some-virtualhost/ -R

Now you can safely reload your apache2 configuration and you’re done

$ sudo /etc/init.d/apache2 reload
Page 1 of 41234»