Archive for the 'General' Category

SSH Port forwarding from remote to local machine

SSH has a wonderful feature called SSH Port Forwarding, also known as SSH Tunneling, which allows you to establish a secure SSH session and then tunnel arbitrary TCP connections through it. Tunnels can be created at any time, with almost no effort and no programming, which makes them very appealing.

Here I’ll illustrate it using an example. Suppose you have installed and configured Jabber Instant Messaging Server (check out to do that on this site here). You found later that in the Server machine, there’s no GUI available and you need to access its graphical web admin interface. In this case, you can easily forward port from Server machine to your own PC to access the admin interface. You might know that ejabberd (Jabber Server) web admin interface is available on port 5280.

Install perl Net::SFTP module in linux

When installing perl Net::SFTP module in CentOS 5 box:

# perl -MCPAN -e 'install Net::SSH::Perl'

It got stuck at:

t/01-compile.t…..ok
t/02-buffer.t……ok
t/03-packet.t……1/10

then I tried installation with force so that it can skip tests if any of them failed:

# perl -MCPAN -e 'force install Net::SSH::Perl'

The module seems installed ok but while using in a script, error occured:
Can’t locate Net/SSH/Perl/Buffer.pm in @INC …

that means, the module still not installed/configured properly. To get it done, I searched for rpms and found rpmforge repository http://dag.wieers.com/rpm/packages/rpmforge-release/ have all the sufficient rpms:

Install java plugin for firefox

You are running firefox and noticed that in a website there’s requirement of java runtime environment for proper viewing of site. Now firefox tries to install but in vain. Here are quick steps to install and configure java plugin for Firefox 3. These steps are tested in CentOS 5:

1. Download Java from here I have downloaded rpm in bin format.

2. Extract rpm from binary and then install it:

$ ./jre-6u5-linux-i586-rpm.bin
$ rpm -ivh jre-6u5-linux-i586.rpm

3. Make softlink to libjavaplugin_oji.so in your Mozilla Plugins directory after making sure that /root/.mozilla/plugins directory exists, else create the plugins directory first. Now as an example, if java is installed in /usr/java, this command will do the trick:

Missing Dependency: libFLAC.so.4 is needed by package libsndfile

In mood to listen some music on my CentOS 5 system, I found that mplayer is not installed.
I’ve followed instructions from http://wiki.centos.org/TipsAndTricks/MultimediaOnCentOS
but stuck with error:

Error: Missing Dependency: libFLAC.so.4 is needed by package libsndfile

I have then forcebly removed following:

$ rpm -e --nodeps flac-1.1.2-27

and installed:

$ wget ftp://rpmfind.net/linux/dag/redhat/el3/en/i386/dag/RPMS/flac-1.1.0-4.rhel3.dag.i386.rpm
 $ rpm -ivh flac-1.1.0-4.rhel3.dag.i386.rpm

This resolved the error and system is now happily playing music.

You may also like to read:
* 5 steps to secure your Linux Server
* Ensuring secure access to production Linux Servers
* Bash script to backup essential log files in Linux
* Quickly change your ssh port from defualt 22 to something higher
* SSH port forwarding from remote to local machine
* Save root or user history to check later
* Install and configure denyhost to prevent brute force attacks

How to change Date, Time and Time Zone in Linux

In Redhat based distro, here’s a quick solution to change your time zone to PST/PDT:

$ mv /etc/localtime /etc/localtime.Old && ln -s /usr/share/zoneinfo/PST8PDT /etc/localtime

Other commands:

Change Time zone to IST:

$ mv /etc/localtime /etc/localtime.Old && ln -s /usr/share/zoneinfo/Asia/Calcutta /etc/localtime

Set the TZ environment variable for quick display time according to preferred Time Zone:

$ export TZ=America/Los_Angeles
$ date

If you have the utility rdate, update the current system time by executing

$ rdate -s pool.ntp.org

You can execute ‘system-config-date’ for setting up date/time and time zone

$ system-config-date

If you’re using Ubuntu, tzconfig is there for you:

$ tzconfig