Wednesday, May 13, 2009

Ruby 1.8 xmlsimple.rb errors solved

Getting these errors when working with rails:

/usr/lib/ruby/1.8/xmlsimple.rb:275: warning: already initialized constant KNOWN_OPTIONS
/usr/lib/ruby/1.8/xmlsimple.rb:280: warning: already initialized constant DEF_KEY_ATTRIBUTES
/usr/lib/ruby/1.8/xmlsimple.rb:281: warning: already initialized constant DEF_ROOT_NAME
/usr/lib/ruby/1.8/xmlsimple.rb:282: warning: already initialized constant DEF_CONTENT_KEY
/usr/lib/ruby/1.8/xmlsimple.rb:283: warning: already initialized constant DEF_XML_DECLARATION
/usr/lib/ruby/1.8/xmlsimple.rb:284: warning: already initialized constant DEF_ANONYMOUS_TAG
/usr/lib/ruby/1.8/xmlsimple.rb:285: warning: already initialized constant DEF_FORCE_ARRAY
/usr/lib/ruby/1.8/xmlsimple.rb:286: warning: already initialized constant DEF_INDENTATION
/usr/lib/ruby/1.8/xmlsimple.rb:287: warning: already initialized constant DEF_KEY_TO_SYMBOL

Solution:

$ cd /usr/lib/ruby/1.8/
$ sudo mv lib/xmlsimple.rb lib/xmlsimple.rb.old
$ sudo mv xmlsimple.rb lib/

Monday, April 20, 2009

SSH and GSSAPIAuthentication

Reading the mail lists and forums you see quite a few people seem to be getting "slow" SSH connections when this option is turned on.

One way to "speed" up the connection is to turn it off, like so:

GSSAPIAuthentication no

in your .ssh/config file or on the command line like so:

ssh -o GSSAPIAuthentication=no


But what it is and what does it do?

GSSAPI stands for Generic Security Services API.

Just like its name suggests is a API that provides a standard interface for communicating with different protocols.

In SSH's case its designed to talk to Kerberos. But in case of Windows it can be made to talk to NTLM.

So what actually happens when SSH communication is initiated?

If you debug the connection you'll see something like this:

debug3: preferred gssapi-keyex,gssapi-with-mic,gssapi,publickey,keyboard-interactive,password

The server offers 'gssapi-keyex' as a possible authentication and the client tries to authenticate against it.

With the options listed above we just turn GSSAPI based authentication off on the client side. But a better solution, in case that you are not using this authentication at all, is to turn it off on the server side in /etc/ssh/sshd_config, likes so:

GSSAPIAuthentication no

Since SSH is almost universal way to connect to remote hosts/devices nowadays,
to insure a consistent authentication using GSSAPI, its very own RFC has been defined: RFC4462.

Friday, February 20, 2009

Suse10: eth0 renamed to eth1

uname -a: Linux sles10 2.6.16.21-0.8-default

I got this message: eth0 renamed to eth1

You can see the offending material in
/etc/udev/rules.d/30-net_persistent_name.rules:

SUBSYSTEM=="net", ACTION=="add", SYSFS{address}=="08:00:27:b8:c1:da", IMPORT="/lib/udev/rename_netiface %k eth0"
SUBSYSTEM=="net", ACTION=="add", SYSFS{address}=="08:00:27:06:67:20", IMPORT="/lib/udev/rename_netiface %k eth1"

Even though, there was only one card attached, I tried to remove the first line eth0 and rename the second interface eth1 to eth0, but no luck.

The dirty solution was to remove both lines and reboot, which resolved the issue.

Friday, February 6, 2009

Perl one liners

Join multiple lines:
perl -le 'print join " ", map { chomp; $_ } <>'

Convert unix timestamps:
perl -e 'print scalar localtime (TIMESTAMP)'

Thursday, February 5, 2009

Command-line Fu

This is such a great idea, I'm surprised nobody thought of it earlier:

Command-line-fu

A sort of like Digg for quick one liners.

Wednesday, February 4, 2009

Time zone calculator

To work out local GMT time use something like:


use POSIX qw(strftime);
strftime "%a %b %e %H:%M:%S %Y", gmtime;

Then either deduct or add in seconds, to work out time in a different time zone. Something like this:

# or for GMT formatted appropriately for your locale:
my $london = strftime "%a %b %e %H:%M:%S %Y", gmtime;
print "London $london\n";

# 8h * 60 min = 240 * 60 sec = 28800
my $seattle = strftime "%a %b %e %H:%M:%S %Y", gmtime(time - 28800);
print "Seattle $seattle 8 hours behind\n";

Nothing crazy, but useful.

Friday, January 9, 2009

Hardware database

The guys at UbuntuHCL have the right idea. They've created a hardware database where you can check compatibility of the hardware.

Going just by the name, as it says Ubuntu in the URL, you would be misled, since it keeps the track on compatibility with the other Unix/Linux OSes.

The great thing is, the reviews are created by the users. The downside is, its not that populated with reviews. So if you are reading this, be good, and fill in your hardware in there, help others :)