SSH Chroot in ISPConfig Centos-4.6
Thu, 02/28/2008 - 00:58 — sandipBelow is reference of how I have setup chroot SSH jail for users in CentOS-4.6 with ISPConfig installed replacing the openssh rpm with the one from chrootssh.sourceforge.net .
It's easy on ISPConfig as support for chroot SSH is now built in with the control panel, you simply need to get chrootSSH installed and then enable the ssh option located in the config file at "/home/admispconfig/ispconfig/
$go_info["server"][& quot;ssh_chroot"] = 1;
If you need for the ssh chroot to access additional application, the file "/root/ispconfig/scripts/shell
Force ProFTPD to listen on only one IP
Sun, 02/24/2008 - 00:10 — sandipIt's not quite as clean as the socket binding under Apache but the principle works something like this.
-
In Standalone mode, to listen on the primary IP of a host use the SocketBindTight directive.
In "/etc/proftpd.conf":
SocketBindTight onTo listen on a interfaces which are not the primary host interface, use the SocketBindTight directive, place your server configuration in a
Port &n bsp; &n bsp; &n bsp; &n bsp; &n bsp; 0
SocketBindTight & nbsp; & nbsp; & nbsp; on
<VirtualHost xxx.xxx.xxx.xxx>
&nbs p; Port 21
&nbs p; DefaultRoot & nbsp; & nbsp; ~
&nbs p; AllowOverwrite &nbs p; &nbs p; on
&nbs p; Umask & nbsp; & nbsp; & nbsp; 002
</VirtualHost>
Install / Setup Nagios on Fedora 7
Thu, 02/14/2008 - 02:01 — sandipThese are supplement notes I had taken down a while back doing an install of nagios and n2rrd on a Fedora-7 box and recently came very handy when doing the install in a redhat (RHEL-3) box as well:
Nagios Install:
# yum install nagios nagios-plugins nagios-plugins-http nagios-plugins-icmp nagios-plugins-ping
On RHEL3, I used (dags rpms) rpmforge. Here is my yum.conf for rpmforge:
[rpmforge]
name = Red Hat Enterprise $releasever - RPMforge.net - dag
baseurl = http://apt.sw.be/redhat/el3/en /$basearch/dag
Notes: I settled for icmp instead of ping, as it is a lot faster. However, icmp required setting setuid for "/usr/lib/nagios/plugins/check
_icmp" for it to work. Also, had to rebuild nagios-plugins from source as root in order for the plugin to be installed.
encode / decode base64 file
Thu, 02/07/2008 - 10:30 — sandipI use squrrelmail in text mode and recently I've had to retrieve a password at Dell. The reset password email however comes with html embeded in base64 encoded text. So my webmail did not show up the embeded html link. With some knowledge of uudecode, I was able to view the exact link to reset the password.
The sharutils package contains the GNU utilities uuencode and uudecode.
Here's a brief background and usage:
uuencode is a program that encodes binary files as plain ASCII text so that they can be sent through electronic mail. The program expands single characters that can't be viewed or printed as normal text into pairs of text characters, and the resulting encoded file is somewhat larger than the original binary file. This process is necessary to prevent mail, news, and terminal programs from misinterpreting the non-text characters in binary files as special instructions.
$ cat test.txt
hello world!
$ uuencode -m test.txt test.txt > test.txt.base64
$ cat test.txt.base64
begin-base64 644 test.txt
CmhlbGxvIHdvcmxkIQoKCg==
====
$ rm test.txt
$ uudecode test.txt.base64
$ cat test.txt
hello world!
First I copied over the actual base64 encoded text from my local email folder which looks similar to:
$ cat dell_reset
DQpUaGlzIGVtYWlsIHdhcyBzZW50 IHRvIHlvdSBpbiByZXNwb25zZSB0by B5b3VyIHJlcXVl
... ...
bGluayBoYXMgYSBsaWZlIHNwYW4g b2YgdGhyZWUgZGF5cyBvbmx5Ljxici AvPg0KPGJyIC8+DQo=
I then added text in the beginning and end to specify the base64 encoded as below:
$ cat - dell_reset <<<"begin-base64 644 dell_reset.txt" > dell_reset.base64
$ echo "====" >> dell_reset.base64
$ cat dell_reset.base64
begin-base64 644 dell_reset.txt
DQpUaGlzIGVtYWlsIHdhcyBzZW50 IHRvIHlvdSBpbiByZXNwb25zZSB0by B5b3VyIHJlcXVl
... ...
bGluayBoYXMgYSBsaWZlIHNwYW4g b2YgdGhyZWUgZGF5cyBvbmx5Ljxici AvPg0KPGJyIC8+DQo=
====
The text was then decoded using:
$ uudecode dell_reset.base64
$ cat dell_reset.txt
This email was sent to you in response to your request to modify your Dell.com account.<br />
Click the link below to go to the Dell site and modify your account:<br />
... ...
sendmail access.db by example
Wed, 02/06/2008 - 00:02 — sandipThe sendmail access database file can be created to accept or reject mail from selected domains.
Since "/etc/mail/access" is a database, after creating the text file, use makemap to create the database map.
# makemap hash /etc/mail/access.db < /etc/mail/access
Below is what my access file currently looks like and can be used as a starting point. All internal addresses have been changed except for spammers!!
# by default we allow relaying from localhost... localhost.localdomain RELAY localhost RELAY 127.0.0.1 RELAY # Allow Connect from local server IPs Connect:207.44.206.144 OK # Accept Mail # accept mail from PayPal paypal.com OK # Reject Mail posterclub@e.allposters.c om REJECT posterclub@email.allpos ters.com REJECT plastmarket.com REJECT jr@jrtr.org REJECT 7b2.606@fe01.atl2.webus enet.com REJECT mysoldpad.com REJECT # Discard Mail 1and1-private-registratio n.com DISCARD # forum admin mails: fictionaluser@gmail.com DISCARD # Reject full mailbox fictionaluser@linuxweb log.com ERROR:4.2.2:450 mailbox full fictionaluser@linuxweblog .net REJECT # Blacklist recipients linuxweblog.net ERROR:550 That host does not accept mail # Spam friend domains: exempt domains from dnsbl list checking Spam:linuxweblog.org FRIEND # Spam friend users: exempt email users from dnsbl list checking # example: # Spam:user@domain.tld FRIEND # clients Spam:fictionalclient@h otmail.com FRIEND # Auto REJECT via hourly cron added below
Easy Drupal maintenance and upgrades
Sat, 01/12/2008 - 17:37 — sandipSince Drupal has been coming out with rapid updates, mainly due to security fixes, it's quite cumbersome to have to keep it up to date. However, with the below setup and the script to help with the maintenance, it was a breeze with the last update. The script has been used to upgrade from 5.5 to 5.6 release.
Note: The script does not currently have any checks (extreme alpha stage) and my Drupal installation is not a standard install so usage may vary. Make sure you understand the script prior to running it. Usual disclaimer applies. You will also need root level access to shell to run the script as it is set to change ownership of files and folders using the "chown" command.
My current Drupal install are based on symbolic links for easy maintenance and upgrades. The layout is as below:
/var/www/html, /var/www/html/site_files, /var/www/html/sites are all symbolically linked to the /var/www/drupal-5.x, /var/www/drupal_files, /var/www/drupal_sites respectively where /var/www/html is the web root.
Document Root = /var/www/html -> /var/www/drupal-5.x Files Folder = /var/www/html/site_files -> /var/www/drupal_files Sites Folder = /var/www/html/sites -> /var/www/drupal_sites
Also, any customization to the .htaccess is on top of the default Drupal code. So the script will automatically prepend the data to the upgraded .htaccess file. Since, I also have the gallery module, the .htaccess file is also set to be writable by apache.
Don't forget to set your site in "maintenance mode" with the default theme, and disable all modules prior to the upgrade. Although, I've done some updates with all modules available without any issues. Also, my custom theme resides in the sites folder and stays untouched with the update.
Place the script in "/var/www" (just outside your document root) and run the update via:
# sh ./update_drupal.sh 5.x
Once completed, run update.php to update any changes to the database. Set site back to production mode, re-applying any customization as necessary.
Debian / Ubuntu command notes for packages and service maintenance ...
Sat, 01/12/2008 - 03:23 — sandipAPT-GET
-
Clean up non-existent data
# apt-get autoclean
# apt-get update
# apt-get install <pkg>
# apt-get -Vsu -o Debug::pkgProblemResolver=yes dist-upgrade
# apt-get -Vu upgrade
# apt-get -Vu dist-upgrade
# apt-cache search <pkg>
# apt-get --purge remove <pkg>
DPKG
-
Install/Update package
# dpkg -i <pgk>
# dpkg -l *<pkg>*
# dpkg --search /path/to/file
#dpkg -L <pkg>
# dpkg -s <pkg>
SERVICES
-
Manage services at init levels.
# sysv-rc-conf
# update-rc.d
Trac and SVN install / configuration notes...
Thu, 01/10/2008 - 12:56 — sandipThe below notes is specifically for centos-4.6 :
Installation:
# rpm -ivh http://apt.sw.be/packages/rpmf orge-release/rpmforge-release- 0.3.6-1.el4.rf.i386.rpm
# yum install httpd subversion mod_python mod_dav_svn
# yum --enablerepo=rpmforge install trac
Instantiating svn:
# mkdir /var/www/svn
# svnadmin create /var/www/svn/project
Initial svn import:
# mkdir -p /tmp/newsvn/{trunk,tags,branch es}
# svn import /tmp/newsvn file:///var/www/svn/project -m "Initial import"
# chown -R apache /var/www/svn/project
# chmod -R go-rwx /var/www/svn/project
Instantiating trac:
# mkdir /var/www/trac
# trac-admin /var/www/trac/project initenv
# mkdir /var/www/{.python-eggs,passwd}
# htpasswd -c /var/www/passwd/.htpasswd <adminuser>
# touch /var/www/passwd/svnauthz
# chgrp -R apache /var/www/trac/project
# chown -R apache /var/www/trac/project/{attachm ents,db,log,plugins}
# chown -R apache /var/www/{.python-eggs,passwd}
# chmod -R o-rwx /var/www/{trac/project,.python -eggs,passwd}
# chmod g+w /var/www/trac/project/conf/tra c.ini
Install trac plugins:
# wget http://peak.telecommunity.com/ dist/ez_setup.py
# python ez_setup.py
# easy_install http://svn.edgewall.com/repos/ trac/sandbox/webadmin/
# easy_install http://trac-hacks.org/svn/acco untmanagerplugin/0.10
# easy_install http://trac-hacks.org/svn/svna uthzadminplugin/0.10
trac.ini conf setup:
[trac]
default_charset=UTF-8
authz_file = /var/www/passwd/svnauthz
[components]
acct_mgr.admin.accountmanage radminpage = enabled
acct_mgr.api.accountmanager = enabled
acct_mgr.htfile.htpasswdstor e = enabled
acct_mgr.web_ui.accountmodul e = enabled
acct_mgr.web_ui.loginmodule = enabled
trac.web.auth.loginmodule = disabled
webadmin.* = enabled
svnauthz.* = enabled
[account-manager]
password_file = /var/www/passwd/.htpasswd
password_store = HtPasswdStore
Apache trac conf setup:
Alias /trac /var/www/trac
<Location /trac>
&nbs p; SetHandler mod_python
&nbs p; PythonInterpreter main_interpreter
&nbs p; PythonHandler trac.web.modpython_frontend
/> &nbs p; PythonOption TracEnvParentDir /var/www/trac
&nbs p; PythonOption TracUriRoot /trac
&nbs p; SetEnv PYTHON_EGG_CACHE /var/www/.python-eggs
</Location>
#<Location /trac/*/login>
# &nb sp; AuthType Basic
# &nb sp; AuthName 'Trac Server'
# &nb sp; AuthUserFile /var/www/passwd/.htpasswd
# &nb sp; Require valid-user
#</Location>
Apache subversion conf setup:
<Location /svn>
DAV svn
SVNParentPath /var/www/svn
# Limit write permission to list of valid users.
# <LimitExcept GET PROPFIND OPTIONS REPORT>
&nbs p; # Require SSL connection for password protection.
&nbs p; # SSLRequireSSL
&nbs p; AuthType Basic
&nbs p; AuthName 'Authorization Realm'
&nbs p; # Trac .htpasswd file used so users will be the same for both
&nbs p; AuthUserFile /var/www/passwd/.htpasswd
&nbs p; Require valid-user
&nbs p; AuthzSVNAccessFile /var/www/passwd/svnauthz
#</LimitExcept>
</Location>
Trac privileges:
# trac-admin /var/www/trac/project permission add admins TRAC_ADMIN
# trac-admin /var/www/trac/project permission add <adminuser> admins
# trac-admin /var/www/trac/projectname permission remove anonymous TICKET_CREATE TICKET_MODIFY etc...
# track-admin /var/www/trac/project permission add devs BROWSER_VIEW CHANGESET_VIEW FILE_VIEW LOG_VIEW &nbs p; \
&nbs p; &nbs p; MILESTONE_CREATE MILESTONE_VIEW REPORT_CREATE REPORT_MODIFY REPORT_SQL_VIEW REPORT_VIEW \
&nbs p; &nbs p; ROADMAP_VIEW SEARCH_VIEW TICKET_APPEND TICKET_CHGPROP TICKET_CREATE TICKET_MODIFY \
&nbs p; &nbs p; TICKET_VIEW TIMELINE_VIEW WIKI_CREATE WIKI_MODIFY WIKI_VIEW
Login as the admin user and setup Trac plugins, permissions etc...
Keep server time in sync with ntp
Fri, 12/07/2007 - 15:45 — sandipNTP is a protocol designed to synchronize the clocks of computers over a network, easy to setup and probably comes packaged with the OS.
Here's what was needed on a Fedora-6:
-
Install the ntp rpm if not already installed.
# yum install ntp
Find a reliable close ntp pool server or you could just use the hub, "pool.ntp.org" and add it to the server list in "/etc/ntp.conf" file.
Make sure your computer's clock is set to something sensible (within a few minutes of the 'true' time) - you could use `ntpdate pool.ntp.org`, or you could just use the date command and set it to your wristwatch, and also synchronize the hardware clock.
Make sure ntp starts up at boot and then start the service:
# /sbin/chkconfig ntpd on
# /sbin/service ntpd start
# ntpq -pn localhost
Anatomy of Linux Kernel
Sun, 11/18/2007 - 10:53 — sandipImmensely useful article for learning about Linux kernel at IBM DeveloperWorks.