Geekblok

B10m, BOK, Joffie - old geeks on a blog

Entries Comments



Category: guides


Streaming your life with Yahoo! Pipes

13 June, 2008 (13:50) | guides, web2.0 | By: B10m

Yahoo! Pipes logoWith a plethora of social websites, it’s hard to keep track of everything. And like with all itches, people will try to make money out of it and come up with sites like FriendFeed, Lifestream, etc.

But what if you want to build something similar yourself? You’d have to download all your RSS feeds, combine them and most likely filter and sort them. Yahoo! Pipes comes in handy!

Read more »

shell tips and trick, part 2

19 January, 2008 (13:31) | guides, technical | By: Joffie

This trick is a bit bash specific instead of a real shell trick. On most unix systems you’ll find the commands dirname and basename. These are rather useless when you have got bash. First we’ll look at dirname.
The manual page of dirname states: dirname - strip non-directory suffix from file name. In bash this would be accomplished by parameter expansion:
$ I=/home/joffie/geekblok.txt; echo ${I%/*}
/home/joffie
The description from the man page of basename is: strip directory and suffix from filenames. So for example:
$ basename /home/joffie/geekblok.txt
geekblok.txt
The same can be accomplished with:
$ I=/home/joffie/geekblok.txt; echo ${I##*/}
geekblok.txt
The suffix part of the basename command can be done in two steps. What the command basename does is strip something from both sides of the string. So stripping suffix .txt from $I too:
$ I=/home/joffie/geekblok.txt; J=${I##*/}; echo ${J%.txt}
geekblok
Bash can also be used when searching and replacing. Take a look at:
$ I=/home/joffie/geekblok.txt; echo ${I/geek/cool}
coolblok.txt
More info can be found in the parameter expansion section of the man page of bash.

shell tips and trick, part 1

15 December, 2007 (16:21) | guides, technical | By: Joffie

Instead of another ssh guide, I thought it was about time for a first shell-scripting guide. In my daily job I often notice scripts that do work, but are not as efficient as could be. Say that I want the process id of the ssh daemon on my system. Loads of people will come up with something like:
ps -ef | grep sshd | grep -v grep | awk '{print $2}'

This does get the process id of sshd, but the above could also be written as:
ps -ef | awk '/sshd$/ {print $2}

And even this can still be written more efficient. Think about what you want to achieve. I asked for the process id of sshd. Basically the following would suffice:
cat /var/run/sshd.pid

Hey, I never really asked for a running sshd. But if I had asked for the process id of a running ssh daemon, the most simple solution would be:
ps -C sshd -o pid=

Or:
pgrep 'sshd'

Both just use one command instead of the four of the first example.

Hiding files in JPEGs

4 December, 2007 (12:19) | guides, images | By: B10m

You’ve probably heard about storing secret messages in JPEGs by means of steganography. But what if you have entire documents that you’d like to hide? As proof of concept, I showed this example to my coworkers.

We start out with a random JPEG, taken from my Flickr account:

fotobok.jpg

Now we create a simple zip file with a text document in it:

$ zip test.zip test.txt

And we cat the two files together:

$ cat fotobok.jpg test.zip > fotobok-test.jpg

File indeed recognizes this as an image:

$ file fotobok-test.jpg
fotobok-test.jpg: JPEG image data, JFIF standard 1.01

And you can see it here too:

fotobok-test.jpg

The only difference now is that we can unzip the file aswell:

$ unzip fotobok-test.jpg
Archive: fotobok-test.jpg

warning [fotobok-test.jpg]: 19881 extra bytes at beginning or within zipfile

(attempting to process anyway)

extracting: test.txt

Tada! Our highly secret test.txt is back!

Ssh tips and tricks, part 5

21 November, 2007 (20:51) | guides, technical | By: Joffie

It has been a while, but it is time for the next guide. In this guide I will dig a bit deeper into the ssh-agent. In the previous guide I noticed the passwordless logins that can be accomplished with ssh keys. I suppose you have still got the dsa key that you generated via that guide (or another one) around.
Remember that you will need to have it passphrase proteced. If you haven’t done that, please do so via:

bq. ssh-keygen -p -f ~/.ssh/id_dsa

Also copy the public key to the server you want to login to

bq. ssh b10m.example.net cat < ~/.ssh/id_dsa.pub “>>” ~/.ssh/authorized_keys

In theory everything should now be set up right to use key authentication, but there might be some caveats..

Read more »