Sharing shell with ytalk on Ubuntu
A good friend of mine years ago used to use a command-line app called ytalk to show me around the bash shell (thanks Sione!). After a short while I stopped needing his help and so I stopped using ytalk. At work we really wanted to shell-share with remote team members who were unable to use the iChat screenshare because of OS and bandwidth limitations.
I remembered that ytalk was such a good tool for being able to see what someone else was doing in the shell and to show off your bash skills. I thought it was going to be easy to setup on Ubuntu, but as it turns out, although its still an available package, it is dead on install.
So…. here is what I ended up doing and I hope that if you do the same you will be ytalk’in in no time..
On ubuntu install ytalk:
sudo apt-get install ytalk
Change the default/broken inetd.comf configuration:
talk dgram udp wait nobody.tty /usr/sbin/in.talkd in.talkd
ntalk dgram udp wait nobody.tty /usr/sbin/in.ntalkd in.ntalkd
to:
talk dgram udp4 wait root /usr/sbin/in.talkd in.talkd
ntalk dgram udp4 wait root /usr/sbin/in.ntalkd in.ntalkd
Note the “4” after the udp and the “nobody.tty” change to “root”
In the /etc/services file, make sure the following lines are in there:
paul@box:~$ sudo grep talk /etc/services
talk 517/udp
ntalk 518/udp
I didn’t have to change anything, but its a good idea to confirm things.
Using YTalk
Initiating the chat:
You can do this in a couple of ways, the first and most obvious way is to coordinate with another person/user and ensure that the two of you are only logged in once to the same box ad then type.
paul@box:~$ ytalk fred
Or if your logged on more than once you can specify the tty in the request after finding out which one it is:
paul@box:~$ who
fred pts/0 2009-11-06 10:50 (208.X.X.X)
fred pts/2 2009-11-06 10:48 (208.X.X.X)
paul pts/3 2009-11-06 14:02 (208.X.X.X)
ytalk fred#2
More on that can be found here: http://manpages.ubuntu.com/manpages/intrepid/man1/ytalk.1.html
Thanks to euphemus for the breakthroughs!
Hope you find ytalk as useful and coolific as I do.
Enjoy!
FAIL: COMPROMISED SSH Public Key on Ubuntu
Last night I was setting up a new application on my server and while I was configuring capistrano I came across this strange problem and didn’t immediately find much help on google, so I thought I would post this to help someone else along.
I had already setup my ssh keys months ago but when I tried to ssh into my subversion repository it would ask me for a password/passphrase and it just about drove me crazy.
I came across this article in google and checked off each potential problem and nothing. Then I saw that my key was conprimized when I ran the “ssh-vulnkey -a” command.
capistrano@allison:~/.ssh$ ssh-vulnkey -a
Unknown (no blacklist information): 2048 5a:b4:d6:94:10:14:e1:a0:35:35:ff:c6:08:e6:9f:10
Not blacklisted: 2048 5f:43:c2:f0:fb:e6:52:c4:90:59:fb:d2:e0:fe:66:d0
Unknown (no blacklist information): 2048 ab:5e:39:5c:33:f0:02:e3:cf:cd:99:84:ca:9e:f8:e1 Paul@paul-hepworths-computer.local
COMPROMISED: 2048 81:85:1d:a7:b1:c6:ff:b2:d5:3f:60:3e:2e:c0:25:5c capistrano@mislice
COMPROMISED: 1024 fa:87:13:5f:0c:01:3e:53:b9:a1:ff:4a:8a:29:b2:a1 capistrano@mislice
So I searched google some more to find out how to fix the problem. I regenerated keys multiple times on my client server and no-dice.
Then after searching and searching I found this tutorial and followed it to update openssl and openssh and regenerate my private keys .
What a relief! (and a waste of time, but now I am secure I guess)
FileMerge Command Line Tools for Subversion
Here are some pretty useful tools for using FileMerge on OSX with the command line subversion.
I stumbled across these tools while I was looking around at how I can better use FileMerge with Subversion
Here is what I did to fully set them up.
# sudo su
# cd /usr/bin
# svn export http://ssel.vub.ac.be/svn-gen/bdefrain/fmscripts/fmdiff .
# svn export http://ssel.vub.ac.be/svn-gen/bdefrain/fmscripts/fmdiff3 .
# svn export http://ssel.vub.ac.be/svn-gen/bdefrain/fmscripts/fmresolve .
# exit
# vim ~/.subversion/config
Be sure to set your diff and diff3 tools to use the fmdiff and fmdiff3
Thanks Bruno De Fraine for publishing these great tools and making my life a little easier. :)
Bulk Zone file Serial Number Increment
I have way too many domain names, so that means that when I want to make a change to my zone template files including a search and replace for certain ips or just changing the email in the zone like I do below. (Or whatever you need to do.)
I first backed up my zone files with a basic but effective cp command:
blah@server ~# cp /var/named /var/named-backup
Then I replaced my email with one that would handle the spam and put it in the right mailbox (/dev/null.) :)
blah@server ~# for file in $(ls /var/named/*.db); do sed -i "s/paul.mydomain.com/dns.omniop.com/g" $file; done
Now that all of the zone files are updated, even if I were to restart my named, the files would not update my slave DNS servers because the serial number in the zones have not changed.
... 2008011502 ; serial, todays date+todays ...
So here is a quick little shell script that I wrote that increments all of my BIND zone files for my DNS server.
#!/bin/bash
for file in $(ls /var/named/*.db);
do
if [ -f $file ];
then
OLD=`egrep -ho "2008[0-9]*" $file`
NEW=$(($OLD + 1))
sed -i "s/$OLD/$NEW/g" $file
echo "fixed $file"
fi
done
There may be a better way of doing this, but I found this very quick and painless.
Now I will hopefully get less spam now that the DNS email scrapers won’t get my email from my zone files.
Hope this helps someone!
VPS restoration from backup kills your InnoDB database -- don't let it happen to you!
A month ago my then VPS provider, JaguarPC, has some really freaky hardware issues, that to this day I have no idea what happened and they ended up restoring a two week old backup of the whole server which included my VPS. When I fired up this blog and a couple of other sites they failed due to mysql table corruption. The corrupt databases that used Myisam tables seemed to repair just fine, but all of my InnoDB databases (Rails uses InnoDB by default when you use migrations) were unrecoverable and I ended up having to try other means for getting my data back or at least as much of my data that I could get back.
Here is what I learned:
- Never assume that your hosts backups of your VPS will work when they are restored because they perform backups while the server is running and databases don’t like that too much.
- Always keep backups of your databases, especially the ones that use the InnoDB table engine, in a SQL dump format.
So here is what I do now to prevent this from happening again:
- Perform your own backups of your databases using the methods that are suggested for your db and db table engines.
- Get the data into SQL so when your VPS is backed up it will properly backup a dump.
Assuming that you have a file that contains a list of databases with one per line, you can do something like the following and then hook up your script t cron.
#!/bin/bash
cd /var/lib/mysql
if [ ! -d sql_backup ]; then
mkdir sql_backup
fi
for db in $(cat databases.txt); do echo $db; mysqldump --single-transaction $db > sql_backup/${db}.sql; done
Good luck, and oh BTW, you might want to get this running on your VPS before your host does the restore. ;)
MySQL on the move from Latin1 to UTF8
A few days a go I had to move a Wordpress blog from one server to another and it turned out to be a bigger project than I had originally thought due to the character set being set to Latin1 on the old server and about 180+ posts that were copied in from Microsoft Word containing strange opening and closing quotes and hyphens. When I did a dump of the database and then reimported the data in to a utf8 database man strange characters showed up in the post. I did what I usually do in situations and started to Google for an explanation. I found this article and it referenced this article and here is what I ended up doing to get the issue solved.
I opened up the raw sql dump file in less and saw the strange characters in the test and they looked something like this:
Don<C3><A2><E2><82><AC><E2><84><A2>t
I looked at the context of the skewed characters and saw immediately that it was an apostrophe that was made "special" by Word and then copied into Wordpress. I removed the "< " and ">" and got C3A2E282ACE284A2 which I then put in the queries that were posted on the articles that I read (links above.)
I repeated the above steps until all of the strange characters were fixed, If you are reading this because you are trying to do the same fix you may find the below helpful.
-- C3A2E282ACE284A2 = ' (apostrophe)
UPDATE wp_posts SET post_content = REPLACE(post_content, UNHEX\('C3A2E282ACE284A2'), "’") WHERE post_content REGEXP UNHEX('C3A2E282ACE284A2');
-- C3A2E282ACC29D = " (close quote)
UPDATE wp_posts SET post_content = REPLACE(post_content, UNHEX('C3A2E282ACC29D'), "\"") WHERE post_content REGEXP UNHEX('C3A2E282ACC29D');
-- E28099 = ' (another form of a singe quote)
UPDATE wp_posts SET post_content = REPLACE(post_content, UNHEX('E28099'), "'") WHERE post_content REGEXP UNHEX('E28099');
-- C382C2B4 = ' (yet another quote)
UPDATE wp_posts SET post_content = REPLACE(post_content, UNHEX('C382C2B4'), "'") WHERE post_content REGEXP UNHEX('C382C2B4');
-- C3A2E282ACC593 = " (open quote)
UPDATE wp_posts SET post_content = REPLACE(post_content, UNHEX('C3A2E282ACC593'), "\"") WHERE post_content REGEXP UNHEX('C3A2E282ACC593');
-- C3A2E282ACE2809C = - (dash/hyphen)
UPDATE wp_posts SET post_content = REPLACE(post_content, UNHEX('C3A2E282ACE2809C'), "-") WHERE post_content REGEXP UNHEX('C3A2E282ACE2809C');
I hope posting this helps someone save a few hours of hunting around. :)
Installing RMagick on OSX
I am working on a little app (link coming soon) with a friend of mine in an effort to practice my rails and now Rmagick skills since my day job doesn't allow me the opportunity.
One of the things that I am building is an logo generator so I need to have an image manipulator/generator of some sort. I have used ImageMagick on many projects in the past so I looked forward to spitting out the classy logos uswing Rmagick.
Like most open-souce installs on OSX and Linux there were some issues that came up along the way.
I first ran the following command on my OSX terminal but got a couple of errors.
# sudo gem install RMagick
...
Can't find Magick-config or GraphicsMagick-config program.
...
I fixed this error by installing the imagemagick-dev version as opposed to imagemagick.
Then when I tried it again I received this error:
...
Can't install RMagick. Can't find libMagick or one of the dependent libraries
...
I resolved this error by searching google and finding this thread so I told fink (one of my osx package managers) that I wanted it to build imagemagick from source with the following command:
# fink --no-use-binary-dist install imagemagick-dev
After I rebuilt ImageMagick form source and inclused all of the dependent libraries i was able to successfully run the following command with no problems:
# sudo gem install RMagick
It worked! Yeah!
Now I will get back to the Rmagick docs. :)

