SSH Tunneling Made Easy

Using OpenSSH on a Linux/Unix system you can tunnel all of the traffic from your local box to a remote box that you have an account on.

For example I tunnel all of my outbound E-mail traffic back to my personal server to avoid having to change SMTP servers, use SMTP-AUTH, etc. when I am behind firewalls. I find that hotel firewalls, wireless access points, and the other various NATing devices you end up behind while traveling often do not play nice.

To do this I use the following:

ssh -f user@personal-server.com -L 2000:personal-server.com:25 -N

The -f tells ssh to go into the background just before it executes the command. This is followed by the username and server you are logging into. The -L 2000:personal-server.com:25 is in the form of -L local-port:host:remote-port. Finally the -N instructs OpenSSH to not execute a command on the remote system.

This essentially forwards the local port 2000 to port 25 on personal-server.com over, with nice benefit of being encrypted. I then simply point my E-mail client to use localhost:2000 as the SMTP server and we’re off to the races.

Another useful feature of port forwarding is for getting around pesky firewall restrictions. For example, a firewall I was behind recently did not allow outbound Jabber protocol traffic to talk.google.com. With this command:

ssh -f -L 3000:talk.google.com:5222 home -N

I was able to send my Google Talk traffic encrypted through the firewall back to my server at home and then out to Google. All I had to do was reconfigure my Jabber client to use localhost as the server and the port 3000 that I had configured.

Posted in Linux, Open Source, Security, Tips - Tricks | Tagged , | Leave a comment

MySQL Change root Password

How do I change MySQL root password under Linux, FreeBSD, OpenBSD and UNIX like operating system over ssh / telnet session?

Setting up mysql password is one of the essential tasks. By default root user is MySQL admin account. Please note that the Linux / UNIX login root account for your operating system and MySQL root are different. They are separate and nothing to do with each other (indeed some admin removes root account and setup admin as mysql super user).
mysqladmin command to change root password

If you have never set a root password for MySQL, the server does not require a password at all for connecting as root. To setup root password for first time, use mysqladmin command at shell prompt as follows:

$ mysqladmin -u root password NEWPASSWORD

However, if you want to change (or update) a root password, then you need to use following command

$ mysqladmin -u root -p’oldpassword’ password newpass

For example, If old password is abc, and set new password to 123456, enter:

$ mysqladmin -u root -p’abc’ password ’123456′

Change MySQL password for other user

To change a normal user password you need to type (let us assume you would like to change password for vivek):

$ mysqladmin -u vivek -p oldpassword password newpass

Changing MySQL root user password using MySQL sql command

This is another method. MySQL stores username and passwords in user table inside MySQL database. You can directly update password using the following method to update or change password for user vivek:

1) Login to mysql server, type following command at shell prompt:

$ mysql -u root -p

2) Use mysql database (type command at mysql> prompt):

mysql> use mysql;

3) Change password for user vivek:

mysql> update user set password=PASSWORD(“NEWPASSWORD”) where User=’vivek’;

4) Reload privileges:

mysql> flush privileges;
mysql> quit

This method you need to use while using PHP or Perl scripting.

Posted in Linux, MySQL | Tagged , , , , , , , , | Leave a comment

An Opportunity in Mobile Computing

An obvious and large opportunity exists in the mobile phone market. At present, developing mobile phone apps requires a development team to obtain specialized skills in either Java/Linux for Google’s Android or Objective C for Apple’s iOS.

A code generator that can output to both Java and Objective C, combined with an abstraction layer, would appear to be an obvious winner.

Clearly, this is a difficult problem to solve, but one that would none the less have huge market potential.

Posted in Linux | Tagged , , | Leave a comment

5 Minutes on Linux: Unable to remove user shares

Problem: I shared a folder using samba sometime back, the share name I used was “MyDocs”, the user was removed later.  After logging in as a new user, I’m unable to use the share name “MyDocs”.

Challenge: for GUI users, one does not have a facility to unshare or manage the orphan shares.

Solution 1 (to unshare): use the command line:

  1. net usershare list
  2. net usershare delete sharename

Solution 2 (to remove orphan shares):

ls -l /var/lib/samba/usershares

sudo rm /var/lib/samba/usershares/sharename

Once this is done, I was able to reuse the share name again.  However, in the current model, it is clear that the shares with same name (even when share is from  different users) they must all be unique.

Posted in Linux, Open Source, Tips - Tricks | Tagged , , | Leave a comment

Python2.4, Python2.5 and Ubuntu 10.04 lucid lynx

Ubuntu lucid lynx does not have Python 2.4 and 2.5 runtimes available in the repositories, so if you are a developer and you are in need of those, then you have two options: One is try to find binaries somewhere else or just compile them from source. In this article, I’m going to point out the steps for compilation.

Go to python.org and download the sources for the version you want. In my case I download Python2.4 Untar the bz2 or gzip file. Go to Python-2.4.4 (my Python version) and cd into Modules. Edit the Setup file and uncomment those modules you need. Amongst them I uncommented the zlib module. You’ll need to install from repos the zlib1g-dev package and the Tcl/Tk one as well. I take for granted you’ve got g++ compiler as well as it is necessary. ./configure, make and sudo make install. Take into account that the python2.4 runtime will be installed in /usr/local/bin/python and /usr/local/bin/python2.4 In my case I deleted the “/usr/local/bin/python” leaving the “/usr/local/bin/python2.4″  (both are the same) to avoid clashing with the python (2.6) in /usr/bin as apparently the shell looks first in /usr/local/bin.

Posted in Linux, Open Source, Tips - Tricks, Ubuntu | Tagged , , , | Leave a comment