Wednesday, July 20, 2011

แผนยึดครองโลกของตำรวจโลก

... to be continued ...

grep out the process called httpd without including the grep command itself in the output

ps auxw | grep "[h]ttpd" # grep out the process called httpd without including the grep command itself in the output (via climagic)

Tuesday, July 12, 2011

cannot run screen after su -

This error message:

Cannot open your terminal '/dev/pts/0' - please check.

occurs when you try to run screen after you "su -" to someone else.  You can skip this error by:

script -c "screen -S main" /dev/null

Friday, July 8, 2011

how to set up vsftpd with pam authentication for name-based virtual hosting

I was surprised how vsftpd didn't work out of the box to support authentication without unix system account.  It took me 2 days to research and did trial and error before I could make it work.  Here is the result.

system: debian

# apt-get install libpam-pwdfile
# mkdir /etc/vsftpd
# cd /etc/vsftpd
# htpasswd -c passwd_ftp a_sample_website

Here I assume that the root directory of your virtual host is /vhdocs/a_sample_website/.

# cd /etc/pam.d
# vi vsftpd

Make sure it looks exactly like this:

# Standard behaviour for ftpd(8).
auth    required        pam_listfile.so item=user sense=deny file=/etc/ftpusers onerr=succeed

# Note: vsftpd handles anonymous logins on its own.  Do not enable
# pam_ftp.so.

# Standard blurb.
#@include common-account
#@include common-session

#@include common-auth
#auth   required        pam_shells.so

# Customized login using htpasswd file
auth    required pam_pwdfile.so pwdfile /etc/vsftpd/passwd_ftp
account required pam_permit.so

Then edit vsftpd's config file:

# vi /etc/vsftpd.conf

It is a long config file.  I will tell you only required lines:

write_enable=YES
local_umask=022
chroot_local_user=YES
# addtitional settings by chaitat
virtual_use_local_privs=YES
connect_from_port_20=YES
guest_enable=YES
guest_username=ftp
user_sub_token=$USER
local_root=/vhdocs/$USER
hide_ids=YES

Restart vsftpd:

# /etc/init.d/vsftpd restart

Modify files' owner:

# chown -R ftp.nogroup /vhdocs/a_sample_website

--
unsigned_nerd

Thursday, July 7, 2011

.htaccess and .htpasswd

sample .htaccess and .htpasswd

.htaccess

AuthUserFile /var/www/tmp/.htpasswd
AuthName "My Private Directory"
AuthType Basic
require valid-user

.htpasswd

admin:$apr1$Y5J7envl$dYoDhqywTT.mD4L6MQIAU/

Sunday, July 3, 2011

debian apt NO_PUBKEY error

A sample error message:

W: GPG error: http://download.virtualbox.org lenny Release: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 54422A4B98AB5139

You can fix it by adding the missing public key by:

# gpg --keyserver subkeys.pgp.net --recv 54422A4B98AB5139
# gpg --export --armor 54422A4B98AB5139 | apt-key add -

how to fix apache warning message: Could not determine the server's fully qualified domain name

Could not determine the server's fully qualified domain name


Newly installation of Apache gave this warning message.  We can fix it by adding this line to your httpd.conf:

# ServerName is to be specified to avoid warning during reload
ServerName MYSERVER

MYSERVER is your host's domain name.

how to block bittorrent

# iptables -I FORWARD -m ipp2p --bit -j DROP