Sascha Tayefeh's Homepage

Blogging about Information Technology

Browsing Posts tagged HowTo

I’ve been looking for a way to prevent ssh brute force attacks. Although they are not particularly dangerous if you have prohibited password login (which you should have done under any circumstances), they had been spamming my log files. Asking the almighty search engine for relief, I found a number of interesting articles about attack blocker, such as DenyHost.

I’ve just installed the package on my private OsX server via MacPorts. However, it took me a while until I found the installation location of all required files. After having touched /etc/hosts.deny (the file used by denyhosts to store suspicious ips for tcp_wrappers to block them), copied /opt/local/share/denyhosts/denyhosts.cfg-dist to somewhere reasonable (e.g. /etc/denyhosts.cfg), modified it to my needs (added E-Mail etc.), I was able to test start DenyHost with:

sudo /opt/local/Library/Frameworks/Python.framework/Versions/2.6/bin/denyhosts.py --config=/etc/denyhosts.cfg

I’ve got a nice email telling me that, deducing from my /var/log/secure.log some IPs were now added to hosts.deny. Furthermore, some interesting data have been stored in /opt/local/share/denyhosts/data.

However, I prefer DenyHost to be running in daemon mode and to synchronize with data collected from the cloud, so I inserted  SYNC_SERVER = http://xmlrpc.denyhosts.net:9911 into denyhosts.cfg and started DenyHost with some additional options:

sudo /opt/local/Library/Frameworks/Python.framework/Versions/2.6/bin/denyhosts.py --config=/etc/denyhosts.cfg --sync --daemon

And now I feel much more comfortable now.

Related Links:

  • Facebook
  • Twitter
  • Yahoo Buzz
  • Delicious
  • Share/Bookmark

When trying to get MPICH2 working on two Debian Lenny machine, I ran into a problem. Actually, /etc/hosts was misconfigured. It was necessary to turn

127.0.1.1    myMachine.myDomain    myMachine

which caused heavy problems when trying to connect from a slave node to the master node using

mpd –host [masterhost] –p [masterport] &

on the slave into

192.168.1.39    myMachine.myDomain    myMachine

which was the actual IP address given to that machine by my DHCP server. I had to repeat this for all nodes using the appropriate IP of the node.

I figured out this problem by reading chapter “Troubleshooting MPDs -> Debugging host/network configuration” of the mpich2-installationguide.pdf – which is worth reading anyway. I learned that running into trouble in such a situation, the command

mpdcheck

or even

mpdcheck -l

is a great tool, since it determines potential host of network configuration problems. There is plenty of debugging information in that manual, so you should always give it a try before searching the internet.

So here is what I did in order to build MPICH2 from scratch:

  1. First, I configured ssh in such a manner, that I was able to logon to any host without using I password. In order to achieve this condition, I created a secret key using ssh-keygen and copied the public key to all slaves. I did not use an empty passphrase, but I started ssh-agent in order to enable quite logon
  2. I got the source from the MPICH2 project homepage and unzip/tar-ed to some temporary directory
  3. cd there and build it using ./configure –prefix=/opt/mpich2 . (However, I preferred building MPICH2 using the Intel Compilers, thus, I set environmental variables CC and CXX: export CXX=icpc && export CC=icc . This step is, of course, not necessary if you build MPICH2 using GNU Compilers)
  4. make && sudo make install
  5. Next, I copied the whole /opt/mpich2 directory to the slave nodes calling scp -r /opt/mpich2 sascha@myslavenode
  6. The PATH and the LD_LIBRARY_PATH must contain the paths to /opt/mpich2/bin and /opt/mpich2/lib
  7. 4. and 5. was  carried out for all nodes, i.e. all nodes had the mpich2 directory physically on their HDs and the paths were set as of 5.
  8. Next, ~/mpd.conf needs to be created. This file contains a list of hosts to be connected to (for example, refer to my mpd.conf file)
  9. On the master, I executed mpdboot -n 2 -f ~/mpd.hosts which establishes connection between 2 hosts for 6 processors (see mpd.conf)
  10. I used mpdringtest 10000 and mpdtrace -l and mpiexec -n 6 hostname respectively in order to validate the connection
  11. Finally, I ran mpdallexit on one machine in order to kill the whole ring

Voila! I’ve got my cluster up and running now :-)

  • Facebook
  • Twitter
  • Yahoo Buzz
  • Delicious
  • Share/Bookmark

This is meant to be a walkthrough rather than a tutorial, thus, this is no good for absolute C++ / Eclipse beginners (you may get lost too soon).

Step I: Create the Shared Library

  1. File -> New -> Project
  2. C/C++ -> C++ Project
  3. Shared Library -> Empty Project (remember to give it a name. Here I use "testlib")
  4. Create a class for Testing: File -> New -> Class. Name it “TestClass“. Also create a simple public method: prototype
    void testWrite(void);
    within TestClass.h and implement something like
    void TestClass::testWrite(void) { std::cout << "From Shared Lib" << std::endl; }
    within TestClass.cpp. Remember to include iostream somewhere
  5. Only if you would like to create a 64bit build: Advanced Settings -> GCC C++ Compiler -> Miscellaneous -> All Options: Add -fPIC
  6. Ctrl+B for build. There should be no errors

Step II: Create some executable that uses the dynamic library

  1. File -> New -> Project
  2. C/C++ -> C++ Project
  3. Executable -> “Hello World C++ Project”
  4. Name it “UseDLL”
  5. Next -> Next -> “Advanced Settings”
  6. GCC C++ Compiler -> Directories ->Add (Button to the right top)
  7. Workspace -> testlib (or enter: ${workspace_loc:/testlib})
  8. Should look like this: Eclipse CDT Library 001
  9. GCC C++ Linker -> Libraries
  10. Add Library (-L): ${workspace_loc:/testlib/Debug}
  11. Add Library search PATH (-l): ${workspace_loc:/testlib/Debug}
  12. Should look like this:
    Eclipse CDT Library 002
  13. Finally select “Paths and Symbols” from the left -> References and select “testlib”:
    Eclipse CDT Library 003
  14. However, this counts for “debug”. Repeat step 10 to 13 for “release” choosing “release” from the upmost tab and replacing “debug” by “release”
  15. OK -> Finish
  16. Ctrl+B should build, however, let’s include the library and do something:
  17. From the Project Explorer, DoubleClick on UseDLL -> src -> UseCPP.cpp and include "TestClass.h"
  18. Also add two lines within main() that create the TestClass object and call its testWrite() method:
    TestClass ti;
  19. ts.testWrite();

Step III: Run (debug) the executable from within Eclipse

  1. First, you must set the environmental variable LD_LIBRARY_PATH: From the Project Explorer Tab, choose UseDLL -> Right-Click -> Debug As -> Debug Configurations
  2. Environment -> New
    Name = LD_LIBRARY_PATH
    Value = ${workspace_loc:/testlib/Debug}
  3. Apply -> Close
  4. Press “F11″ key for Debug -> Select “Use configuration specific setting” -> “Standard Create Process Launcher” -> OK
  5. Now the debug view should appear
  6. Set a break point (Ctrl+Shift+B) at the UseDLL.cpp line that contains “ts.testWrite();“:
    Eclipse CDT Library Debugging Breakpoint 004
  7. Press “F8″ to “Resume”
  8. When the above mentioned line is reached, press “F5″ to “Step Into” the method
  9. Voila! You’re within the code of you dll:
    Eclipse CDT Library Debugging - Jump into a method 005
  • Facebook
  • Twitter
  • Yahoo Buzz
  • Delicious
  • Share/Bookmark

I was curiouse what exactly the difference is between the two Nikon bodies D40 and D90. Furthermore I took the chance and tested two lenses: The first one is a prime lense by Nikon: The first one is a prime portrait lense, Nikkor 50mm F/1.8, which has been subject of many positive reviews. The secound one is a standard zoom shipped with the D40 body, 35-55mm F/3.6-5.6.

Please note that this is no professional, commercial, scientific, accurate or what-ever reliable test. This is just a quick-and-dirty field-experiment, so please don’t blame me for anything. Only instrument to measure differences was my eye, so this could be rather a subjective view. THERE IS NO WARRANTY FOR THE DATA AND THE RESULTS PRESENTED HERE, AT ALL! However, there was no post-edition carried out on the images but some shrinking using GIMP.

Fine.

Now here is what I did: I took some shots of a typical outdoor scene and was interested in the high-contrast area and the distant details. Here is the result:

Review Nikon D40 / D90 and Nikkor 50mm F1.8D

So far, I could not determine any big difference in quality. However, let’s have a closer look at the details. Mind the red boxes marking some areas of the upper left image. Here’s the zoom:

Details of Nikon D40 vs D90

As far as -1- is concerned, I am quite satisfied with all results – I cannot see any chromatic aberration and the lines are sharp. The overall impression is that, at ISO200, 8.0f and 1/800s, there is hardly difference. This is good for me, since these are the most common settings I use. However, keep in mind that this result may (and propably will) change drastically when changing any of the mentioned parameters, particularly at greater ISO and at the shutter opened wider.

In -2- I think the D40 using Nikkor 50mm is slightly less sharp, however, my overall impression is again that there is hardly difference.

I don’t want to make any conclusion here – open the pictures and make your own conclusion. However, for such a scene (a daylight outdoor scene) I’d say that both bodies and lenses provide similar quality. And remember: This is my personal view and THERE IS NO WARRANTY FOR THE DATA AND THE RESULTS PRESENTED HERE, AT ALL!

  • Facebook
  • Twitter
  • Yahoo Buzz
  • Delicious
  • Share/Bookmark

Adobe’s “Generic Postscript Printer” can be downloaded here. However, by default, it prints text in grey only. This is, because it needs a the postscript colour definitions to be loaded during installation process. In order to do so, start the installer, choose “FILE” as port and after this dialogue you will be asked what printer you want to choose. The only entry you see is “Generic Postscript Printer”. Now download the file defpscol.ppd (mirror of defpscol.ppd) and select it by browsing to the place you put it within the Adobe installer dialogue.  Choose it and you’re done.

  • Facebook
  • Twitter
  • Yahoo Buzz
  • Delicious
  • Share/Bookmark

Creating PDF documents is quite easy. For instance, Open Office is capable of exporting PDF while Adobe® Acrobate, which is a professional solution by Adobe® Systems, offers a wide range of additional features. One of the most powerful features is creation of PDF/A documents.  This special format creates PDFs which is meant for long-term archiving.

However, there is a very useful free open-source tool called PDFCreator which is also capable of creating PDF/A documents.  You only need to download PDFCreator and follow these instructions:

  • Print any document from any application you like
  • As the printer, choose PDFCreator
  • Click on “O.K.” or “Print” or whatever
  • A dialog pops up. Click on “Properties”
  • To the left, click on “Program” (if not already chosen)
  • Click on “Ghostscript” (which is actually the engine that creates PDFs)
  • Copy and paste the following line into the upper text box (“Additional Ghostscript Parameters”):

    -dPDFA|-f|<gslib>


  • Click on “Save” and again on “Save”

You are done. A PDF/A document is created. You may want to check this. If you have e.g. Adobe® Acrobate Reader installed, all you need to do is to open the just created PDF and have a look at small bar to the very left. You should see a small icon which reads “PDF” at its top left and shows the letter “i” at its bottom right. This indicates that there are additional information available. Click on that icon. You should see “Conformance. Standard: PDF/A-1B. ISO Name: ISO 19005-1″. If so, you document is actually a PDF/A one.

  • Facebook
  • Twitter
  • Yahoo Buzz
  • Delicious
  • Share/Bookmark

Prerequisite

This is a summary of the steps you need to take in order to make use of Google’s services from your local client. Here is a list of software you need to download and install:

  • Mozilla Thunderbird: This is a free e-mail client. Calendar and task functionality will be added by some add-ons (see next bullets)
  • Lightning: This is an add-on for Thunderbird. Download it, start Thunderbird and from the menu bar select “Extras” -> “Add-Ons” and press the “Install” button. Choose the download, wait until installation has finished and restart Thunderbird
  • Provider for Google Calendar: Another add-on for Thunderbird. This one enables bidirectional communication with Google calendar. Just install it
  • Google Contacts 0.5.51: Another add-on for Thunderbird. This one is used to synchronize the address books of Thunderbird and Google
  • Gmail IMAP Account Setup: A wizard for setting up a google IMAP in Thunderbird. Google’s IMAP account uses lables (tags) which is not so straight-foreward to cope with. This wizard not only sets up your account easily, but it also performs some optimizations. Use it rather than setting up your account manually

Set-up Google Mail

  • In Thunderbird, choose “Extras” -> “Accounts” from the menu bar and press “New Account”
  • Choose “Google Mail IMAP”
  • Just enter your login name. The wizard will do the rest for you.

Add a Google Calendar

First, you need to get the URL of your calendar

  • Go to the Google Calendar site using your internet browser
  • Choose “Preferences” (top right)
  • Choose “Calendar” from the tab that appears
  • Click on the calendar name
  • Scroll down
  • Click on the “XML” button, preferably the one of your private adress
  • Right click on the link and choose “Copy Link”

Now add the link within you clipboard to Thunderbird’s calendar:

  • In Thunderbird, choose “Calendar” from the tab at the left bottom
  • From the menu bar, choose “Calendar” -> “New Calendar”
  • Choose “From Network” and continue
  • Choose “Google Calendar” and paste the URL you just copied into the text field
  • Finally, choose a name, a colour and you’re done
  • Setup the “Contacts” add-on. It is pretty easy, you’ll find your way

Celebrate …

  • Facebook
  • Twitter
  • Yahoo Buzz
  • Delicious
  • Share/Bookmark

I’ve been trying to find out the best way to create an ePub-format document. Of course, I could have used a well-known Adobe product, however, I found a way of creating such books without the use of any commercial software. Here’s the list of free software you need:

  • Amaya: Your text needs to be a valid xhtml document. You could use any of your favoured text or xml editor. This one is my favoured. Remember to use “xhtml 1.1″. However, if you think you are familiar enough with XHTML, you could use any text editor you like
  • Calibre: This is the converter program that turns your xhtml into an ePub document

Oops … that’s it. Two programs only.

Now open Amaya and create a XHTML 1.1 document. Save it. It is important to make excessive use of headers with the class="chapter" attribute. Here is an example of a minimal hello-world.xhtml document:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
      "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
  <title>Hello World</title>
  <meta name="generator" content="Amaya, see http://www.w3.org/Amaya/" />
</head>
<body>
<h1 class="chapter">Hello World: Chapter 1</h1>
<p>This is the text of the first chapter.</p>
<h1 class="chapter">Hello World: Chapter 2</h1>
<p>And some more text. Remember that the header tag must contain the
<code>class="chapter"</code> attribute.</p>
</body>
</html>

Mind the red class attribute. It is a good idea to generate a minimal stylesheet (.css) file that solely contains a definition of the chapter class, e.g.:

.chapter {}

and bind it to your xhtml document using <link href="standard.css" rel="stylesheet" type="text/css" />. Why? Well, this way the chapter style shows up in Amaya’s style tab from which you can choose it easily when creating a header.

If you want to make sure your XHTML document is valid, use html tidy in order to check it:

tidy -asxhtml -utf8  -i -m YOURDOCUMENT.html

Well, the rest is straight foreward: Start Calibre and import you xhtml document. Add meta tags and create your ePub document.

  • Facebook
  • Twitter
  • Yahoo Buzz
  • Delicious
  • Share/Bookmark

If you have ever been searching for a free command-line zip/unzip for windows, try Info-Zip ;-)

Btw, I couldn’t find a binary compilation at their sourceforge resource, so I got what I wanted from their ftp-site.

  • Facebook
  • Twitter
  • Yahoo Buzz
  • Delicious
  • Share/Bookmark

PGP relies on the principle of the “Web Of Trust“. It also offers a service that allows for signing your key by PGP itself. It is called “PGP Global Directory Verification Service” and is quite easy to handle:

  1. Go to http://keyserver1.pgp.com/vkd/ and upload your key.
  2. You’ll receive an e-mail by PGP. Open this e-mail and click on the provided link to finalize the verification process.
  3. Check the fingerprint and continue.
  4. Now download the verified key and click on o.k.
  5. Import the key.
  6. Update the public key-servers

Your done.

  • Facebook
  • Twitter
  • Yahoo Buzz
  • Delicious
  • Share/Bookmark
Powered by WordPress Web Design by SRS Solutions © 2010 Sascha Tayefeh's Homepage Design by SRS Solutions

Switch to our mobile site