Friday, October 15, 2010

Using ssh as proxy

To create ssh tunnel is very easy. Let's say you want to use machine1.example.com as your ssh proxy, your username is foo and you choose port 8080 on your localhost to be your local proxy port. Type below command on your localhost:

$ ssh -D 8080 foo@machine1.example.com
Once connected, set your browser to use Socks5 proxy on port 8080 on your local machine. For firefox, the setting is "Tools -> Options -> Advanced -> Network -> Settings -> Manual proxy configuration" and follow below picture for the proxy setting. Just make sure to keep the ssh connection connected to reap the ssh proxy benefits :)



That's all :)

Cygwin man search problem

If you are a windows user, and you use cygwin, there is a problem with man page. The search function is a bit weird, where it cannot find something like "-D" in ssh man page. To overcome this, you have to set the LANG environment variable to c. To do this, just add export LANG=c to your .bashrc:

$ echo "export LANG=c" >> .bashrc

That's all folks :)

Thursday, October 7, 2010

Forcing user to change password the first time they log in

If you are creating new user in your machine, and you would like them to change password the first time they login, using command chage is the way. Let's say our user is foo.

# chage -d 0 foo
where -d is for lastday. When we set it to 0, it will ask for password change the first time foo logs in.

That's all folks :)

Wednesday, August 11, 2010

Installing apache mod_fastcgi(fastcgi module) on CentOS 5

In the previous post, I have written about installing apache mod_fcgid module to enable fastcgi support on apache. This time, I will write on how to install mod_fastcgi module to enable fastcgi module on apache installed on CentOS 5. Since by the time of this writing, there is no rpm for apache mod_fastcgi, we have to compile the mod_fastcgi module.

1. Install requirements for compilation

# yum install httpd-devel apr apr-devel libtool

2. Download latest mod_fastcgi source code
# cd /opt
# wget http://www.fastcgi.com/dist/mod_fastcgi-current.tar.gz

3. Untar the package.
# tar -xvzf mod_fastcgi-current.tar.gz

4. Install the module. You can find the installation guide on the INSTALL.AP2 file. We have to specify top_dir in the make and make install commands because we install apache2/httpd using yum
# cd mod_fastcgi-2.4.6
# cp Makefile.AP2 Makefile
# make top_dir=/usr/lib/httpd
# make install top_dir=/usr/lib/httpd

5. Add "LoadModule fastcgi_module modules/mod_fastcgi.so" to /etc/httpd/conf/httpd.conf to tell apache to load the new module

6. Restart apache
# /etc/init.d/httpd restart

7. You can assure that the mod is loaded by apache2, by looking at /var/log/httpd/error_log
# grep -i "FastCGI" /var/log/httpd/error_log 

[Wed Aug 11 12:26:27 2010] [notice] FastCGI: process manager initialized (pid 8853)

That's all :)

Installing apache mod_fcgid(fastcgi module) on CentOS 5

For apache to support FastCGI, you have to install either mod_fastcgi or mod_fcgid. In this example, I will show how to install mod_fcgid on existing apache webserver on centos 5.

First of all, the rpm is available at kbsingh's centos testing repository.To install kbsingh's centos repository:

1. Download kbsingh-CentOS-Extras.repo to /etc/yum.repos.d/

# cd /etc/yum.repos.d
# wget http://centos.karan.org/kbsingh-CentOS-Extras.repo

2. Enable karansingh's testing repo by setting gpgcheck to 0 and enabled to 1 in the [kbs-CentOS-Testing]
# sed -i "s/enabled=0/enabled=1/g" /etc/yum.repos.d/kbsingh-CentOS-Extras.repo

3. Install mod_fcgid
# yum install mod_fcgid

4. Restart apache, and verify whether fcgid_module is available by using the second command below
# /etc/init.d/httpd restart
# httpd -t -D DUMP_MODULES

5. If the module is still not loaded, add "LoadModule fcgid_module modules/mod_fcgid.so" to your /etc/httpd/conf/httpd.conf, and restart apache.


That's all :)