Setting up an SSH tunnel
ssh -2 -N -f -L 192.168.0.10:8888:172.16.0.10:80 root@localhost
-2
forces ssh version 2
-N
Do not execute a remote command. This is useful for just forwarding ports (protocol version 2 only).
-f
forces ssh to run in the background
-L
[bind_address:]port:remote_host:hostport
root@localhost
is the user that you create the connection with
Here is my example tunnel script:
#! /bin/sh
# Starts a listening daemon that captures SMDR information
# Author: Jim Lucas <jlucas@cmsws.com>
# Version: 0.0.1
set -e
DESC="PBX Tunnel"
PIDFILE=/var/run/tunnel.pid
L_IP=192.168.1.10
L_PORT=8888
R_IP=192.168.0.10
R_PORT=80
#
# Function that starts the daemon/service.
#
d_start() {
if [ -f $PIDFILE ]; then
echo "$DESC already running: PID# `cat $PIDFILE`"
exit 1
else
echo "Starting $DESC"
nohup /usr/bin/ssh -2 -N -f -L $L_IP:$L_PORT:$R_IP:$R_PORT root@localhost 1>/dev/null
sleep 0.5
ps auxww | grep "$L_IP:$L_PORT:$R_IP:$R_PORT" | grep -v grep | awk -F' ' '{print $2}' > $PIDFILE
echo "$DESC Started #`cat $PIDFILE`"
fi
}
#
# Function that stops the daemon/service.
#
d_stop() {
if [ -f $PIDFILE ]; then
echo -n "Stopping $DESC"
kill `cat $PIDFILE`
rm $PIDFILE
echo "."
else
echo "$DESC is not running"
exit 1
fi
}
case "$1" in
start)
d_start
;;
stop)
d_stop
;;
status)
if [ -f $PIDFILE ]; then
echo "$DESC is running: PID# `cat $PIDFILE`"
else
echo "$DESC is not running"
fi
;;
cleanup)
PID="`ps auxww | grep "$L_IP:$L_PORT:$R_IP:$R_PORT" | grep -v grep | awk -F' ' '{print $2}'`"
kill $PID
rm $PIDFILE
;;
restart|force-reload)
d_stop
sleep 0.5
d_start
;;
*)
echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload}" >&2
exit 1
;;
esac
exit 0
Setting up package management
# uname -a
OpenBSD serv0.cmsws.com 4.3 GENERIC#698 i386
# PKG_PATH=
ftp://ftp.usa.openbsd.org/pub/OpenBSD/4.3/packages/i386/∞
# export PKG_PATH
# pkg_add rsync
Different CLI options
find ./ -type f -name "*.jpg" | sed -e "s/\(.*\)/\"\\1\"/" | xargs rm
Crontab layout
When issued as "crontab -e" this is the correct format
minute (0-59)
| hour (0-23)
| | day of the month (1-31)
| | | month of the year (1-12 or Jan-Dec)
| | | | day of the week (0-6 with 0=Sun or Sun-Sat)
| | | | | commands
| | | | | |
#### Sunday at midnight
0 0 * * 0 /bin/sh somecommandhere
When issued as "crontab -e" this is the correct format
minute (0-59)
| hour (0-23)
| | day of the month (1-31)
| | | month of the year (1-12 or Jan-Dec)
| | | | day of the week (0-6 with 0=Sun or Sun-Sat)
| | | | | user account to run command as
| | | | | | commands
| | | | | | |
#### Sunday at midnight
0 0 * * 0 root /bin/sh somecommandhere
How to mount different things
First off make your mount points
# mkdir /mnt/cdrom
# mkdir /mnt/usb
# mkdir /mnt/hd2
1. mount CDROM at start up with /etc/fstab
# echo "/dev/cd0a /mnt/cdrom cd9660 ro,nodev,nosuid,noauto 0 0" >> /etc/fstab
# mount /mnt/cdrom
2. mount iso
# vnconfig svnd0 /usr/local/share/4.1.iso
# mount -t cd9660 /dev/svnd0c /mnt/cdrom
3. unmount iso
# umount /mnt/cdrom
# vnconfig -u svnd0
4. mount usb
# mkdir /mnt/usb
# mount_msdos /dev/sd0i /mnt/usb
5. unmount usb
# umount /mnt/usb
There are no comments on this page. [Add comment]