Enable Net:SSH2 to connect to EXSi

November 12th, 2012

1. Enable SSH from vSphere Client
2. ssh to the vSphere server and edit /etc/ssh/sshd_config
change
PasswordAuthentication no
to
PasswordAuthentication yes

3. restart ssh /etc/init.d/SSH restart

SFTP only server in centos 5.X

August 17th, 2012

configuration file:

/etc/ssh/sshd_config-sftponly


# ZYV
PasswordAuthentication yes
PermitRootLogin no
PidFile /var/run/sshd-sftponly.pid
Port 2234
Protocol 2
UsePAM no

Subsystem sftp internal-sftp

ChrootDirectory /srv/sftp
AllowTcpForwarding no
X11Forwarding no
ForceCommand internal-sftp

Init script: /etc/init.d/sshd-sftponly

#!/bin/bash
#
# Init file for SFTP-only OpenSSH server daemon
#
# chkconfig: 2345 55 25
# description: SFTP-only OpenSSH server daemon
#
# processname: sshd-sftponly
# config: /etc/ssh/ssh_host_key
# config: /etc/ssh/ssh_host_key.pub
# config: /etc/ssh/ssh_random_seed
# config: /etc/ssh/sshd_config-sftponly
# pidfile: /var/run/sshd-sftponly.pid

# source function library
. /etc/rc.d/init.d/functions

RETVAL=0
prog=”sshd-sftponly”

# Some functions to make the below more readable
SSHD=/usr/sbin/sshd-sftponly
PID_FILE=/var/run/sshd-sftponly.pid

# ZYV
LOCK_FILE=/var/lock/subsys/sshd-sftponly
OPTIONS=” -f /etc/ssh/sshd_config-sftponly ”

runlevel=$(set — $(runlevel); eval “echo \$$#” )

start()
{
cp -af /etc/localtime /var/empty/sshd/etc

echo -n $”Starting $prog: ”
$SSHD $OPTIONS && success || failure
RETVAL=$?
[ “$RETVAL” = 0 ] && touch $LOCK_FILE
echo
}

stop()
{
echo -n $”Stopping $prog: ”
if [ -n “`pidfileofproc $SSHD`” ] ; then
killproc $SSHD
else
failure $”Stopping $prog”
fi
RETVAL=$?
# if we are in halt or reboot runlevel kill all running sessions
# so the TCP connections are closed cleanly
if [ “x$runlevel” = x0 -o “x$runlevel” = x6 ] ; then
killall $prog 2>/dev/null
fi
[ “$RETVAL” = 0 ] && rm -f $LOCK_FILE
echo
}

reload()
{
echo -n $”Reloading $prog: ”
if [ -n “`pidfileofproc $SSHD`” ] ; then
killproc $SSHD -HUP
else
failure $”Reloading $prog”
fi
RETVAL=$?
echo
}

case “$1″ in
start)
start
;;
stop)
stop
;;
restart)
stop
start
;;
reload)
reload
;;
condrestart)
if [ -f $LOCK_FILE ] ; then
stop
# avoid race
sleep 3
start
fi
;;
status)
status -p $PID_FILE openssh-daemon
RETVAL=$?
;;
*)
echo $”Usage: $0 {start|stop|restart|reload|condrestart|status}”
RETVAL=1
esac
exit $RETVAL

Some directory/lib setup…

mkdir -p /srv/sftp/{home,lib,sbin}
ln /lib/ld-2.5.so /srv/sftp/lib
ln /lib/ld-linux.so.2 /srv/sftp/lib
ln /lib/libc-2.5.so /srv/sftp/lib
ln /lib/libc.so.6 /srv/sftp/lib
ln /sbin/nologin /srv/sftp/sbin
ln -s /usr/sbin/sshd /usr/sbin/sshd-sftponly
chkconfig –add sshd-sftponly
chkconfig sshd-sftponly on
service sshd-sftponly start
groupadd sftponly

Adding a user

useradd sftpuser -s/sbin/nologin
usermod -a -G sftponly sftpuser
mkdir -p /srv/sftp/home/sftpuser
chown -R sftpuser:sftponly /srv/sftp/home/sftpuser

Example usage

sftp -P 2234 sftpuser@<IP or hostname>

Flash transparent and z-index issue on IE (7 , 8)

August 17th, 2012

<div style=”z-index:-1;”>
<object classid=”clsid:D27CDB6E-AE6D-11cf-96B8-444553540000″ codebase=”http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0″ width=”910″ height=”178″>
<param name=”movie” value=”images/menu.swf” />
<param name=”quality” value=”high” />
<param name=”wmode” value=”transparent” />
<embed src=”images/menu.swf” quality=”high” pluginspage=”http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash” type=”application/x-shockwave-flash” width=”910″ height=”178″ wmode=”transparent”></embed>
</object>
</div>

Youtube RSS Feed

August 3rd, 2012

http://www.youtube.com/rss/user/yourchannelname/videos.rss
or
http://gdata.youtube.com/feeds/api/users/yourchannelname/uploads

My List of Useful Apps for Windows 7

July 30th, 2012

7-zip
Acrobat Reader
Microsoft Security Essential
Chrome
Dropbox
FileZilla
Firefox
Flash
ImgBurn
iTunes
Java JRE
MS Office
Microsoft .NET Framework
MSN Live Messenger
Notepad ++
Paint.net
Quicktime
SilverLight
TeamViewer
VLC Player

Mapping iostat to LVM Volume Name

July 25th, 2012

iostat -x 1 -N

avg-cpu: %user %nice %system %iowait %steal %idle
4.95 0.00 0.99 94.06 0.00 0.00

Device: rrqm/s wrqm/s r/s w/s rsec/s wsec/s avgrq-sz avgqu-sz await svctm %util
sda 2.00 23.00 127.00 50.00 2960.00 19160.00 124.97 105.46 652.45 5.65 100.00
sdb 0.00 21.00 0.00 9.00 0.00 152.00 16.89 0.31 19.56 15.11 13.60
ddf1_4035305a8680c3272020202020202020c71dbd673a354a45 0.00 0.00 128.00 38.00 2944.00 304.00 19.57 6558.13 35088.59 6.02 100.00
ddf1_4035305a8680c3272020202020202020c71dbd673a354a45p1 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
ddf1_4035305a8680c3272020202020202020c71dbd673a354a45p2 0.00 0.00 128.00 38.00 2944.00 304.00 19.57 6558.13 35088.61 6.02 100.00
VolGroup00-LogVol00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.95 0.00 0.00 94.70
VolGroup00-LogVol05 0.00 0.00 1.00 34.00 8.00 272.00 8.00 13.30 658.74 28.57 100.00
VolGroup00-LogVol03 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
VolGroup00-LogVol04 0.00 0.00 11.00 1.00 136.00 8.00 12.00 16.56 4613.42 83.33 100.00
VolGroup00-LogVol02 0.00 0.00 0.00 1.00 0.00 8.00 8.00 6.90 898.00 1000.00 100.00
VolGroup00-LogVol01 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
VolGroup00-LogVol06 0.00 0.00 0.00 2.00 0.00 16.00 8.00 0.98 0.00 244.50 48.90
VolGroup00-LogVol07 0.00 0.00 116.00 0.00 2800.00 0.00 24.14 6519.45 49518.97 8.62 100.00

ESXi 5.x Allow SMTP Firewall Setup

July 23rd, 2012

Create this file:
/etc/vmware/firewall/smtp.xml

<ConfigRoot>
<service id=”0033″>
<id>smtp</id>
<rule id=’0000′>
<direction>outbound</direction>
<protocol>tcp</protocol>
<porttype>dst</porttype>
<port>25</port>
</rule>
<enabled>true</enabled>
<required>false</required>
</service>
</ConfigRoot>

 

Restart Firewall Services
esxcli network firewall refresh

To enable persistency after reboot

copy smtp.xml to a place that have persistant storage, then

vi /etc/profile.local (5.1) or vi /etc/rc.local (5.0)

add

cp /vmfs/volumes/nas03.iscsi/firewall/smtp.xml /etc/vmware/firewall/smtp.xml
esxcli network firewall refresh

replace /vmfs/volumes/nas03.iscsi/firewall/smtp.xml with the storage location

Also upon restart, need to ssh logon to trigger the effect (no idea why it only execute only during ssh logon)

JQuery to Post to a page in Background

May 15th, 2012

Very simple and useful trick.

$.post(“Test.html”);

Mirroring a website to HTML

February 25th, 2012

if you need to migrate a website from one service provider to another and found you don’t have access to the files or backup on the server, you can try to migrate using the httrack utility.

 

Example

httrack “http://www.exmaple.com/” -O “/home/www/www.exmaple.com/htdocs/” -%v -r 1

 

Useful iPhone / Android Web App Tags

December 10th, 2011

Home Screen ICON

<link rel=”apple-touch-icon-precomposed” href=”icon.png”/>

Disable Zoom in and out

<meta name=”viewport” content=”width=device-width; initial-scale=1.0; maximum-scale=1.0; user-scalable=no;”/>

Input Filter

<input type="text"
       autocorrect="off"   // Only works for iPhone
       autocapitalize="on" // Only works for iPhone
       placeholder="Put in some text here" />