Mar 042011
 
 March 4, 2011  Posted by jason at 1:33 pm documentation, Tutorial , , , , , , , , , ,  No Responses »

Here are some random notes that I find useful. I also tend to forget and use as reference.

[] Vim reference

:e filename (open filename)
:q! (quit, don’t save)
:x (write if changed, otherwise exit)
a (insert after)
A (insert after line)
h j k l (left, down, up, right)
$ (move to end of line)
^ or 0 (move to beginning of line)
G (move to end of file)
:n (move to “n” line, n=number)
x (delete to the right)
X (delete to the left)
D (delete to the end of line)
dd (delete current line)
yy (yank/copy current line)
V (begin highlight, up and down to select “y” to yank selection)
vn (yank “n” lines below cursor, n=number)
p (put/paste)
u (undo)
/string (search for “string”)
n (search for next string match)
:s/yellow/green/gc (replace yellow with green, g is for global, each match is replaced in a line, instead of the first match in a line. c is for confirm/ask)
:%s/yellow/green/g (replaces yellow with green on the entire page)
:s:/usr/local/bin:/opt/users/bin:g (use something other than / as delineation so you don’t have to escape “/”. Like this nasty example: :s/\/usr\/local\/bin/\/usr\/loca\/bin)

[] find command
find . -name “name” -exec [command goes here] {} \;
find . -type d -exec chmod 750 {} \;
find . -type f -exec chmod 760 {} \;
find /home/BACKUP -mtime +14 -exec rm -fr {} \;
-mtime options:
n exactly n days
+n more than n days
-n less than n days

to convert all backslash \ to forward slash /
find . -type f -iname *.xml -exec sed -i ‘s:\\:/:g’ {} \;

[] Rename multiple files

remove space from all files ending in .mp3
rename ‘s/ //’g *.mp3

rename all files ending in .ZIP to .zip
rename ‘s:\.ZIP:\.zip:’ *.ZIP

[] Sending mail with telnet:
telnet hostname 25
helo me
mail from:myaddress@mydom.com
rcpt to:youraddress@yourdom.com
data
This is a test
.
(thats a newline [enter] – period – and another newline [enter])

[] Fix MBR for windows

http://ms-sys-free.sourceforge.net/

from gnulinux:
ms-sys -m /dev/hda

from msdos or nt recovery console:
fdisk /mbr

[] Batch and snippets (yuck)

http://www.allenware.com/icsw/icswidx.htm

echo Cleanup .bak files older than 7 days
forfiles /p d:\backup /m *.bak /d -7 /c “cmd /c del /q @path”

echo Set variable date as yyyymmdd
set date=%date:~-4,4%%date:~4,2%%date:~-7,2%
echo %date%

[] Filesystem stuff

make image of sda
dd if=/dev/sda of =sda.img bs=1M
backup mbr
dd if=/dev/sda of=mbr.backup bs=512 count=1
mount image
losetup /dev/loop0 sda.img
mount /dev/loop0 /mnt

xfs filesystem and xfsprogs
Determine the amount of fragmentation on sda2
xfs_db -c frag -r /dev/sda2

Filesystem re-organizer, by default, with no arguments. It re-organizes files in mounted partitions for 2 hours. Use -t to change the time.)
xfs_fsr

[] Recover Files
testdisk (recover lost partitions)
photorec (part of the testdisk suite)
foremost sda.img
-t (type doc,jpg,exe etc. all is default)
-a (no error detection, recovers partial files)
-d (indirect block, use for nix filesystems)
-o (output dir)
-T (timestamp output dir)

[] KVM Virtualization

Interface config for bridging to virtualized client /etc/network/interfaces
auto eth0
iface eth0 inet dhcp
auto br0
iface br0 inet dhcp
bridge_ports eth0
bridge_stp off
bridge_maxwait 5

[] KVM with Windows

The best way to get virtio is on install. Download the block driver floppy image and attach it, I use virt-manager. Set your hard drive to type virtio and start your windows install. It will will prompt you to press f6 to install third party drivers. Then press S (you have a disk from a third party manufacturer, your floppy image)

If you already have a disk type IDE and want it to be virtio (better). Then do this:
1. Create a temporary image
kvm-img create -f qcow2 temp-virtio.img 1G
2. Shutdown your virtual machine and attach temp-virtio.img as a hard drive, as type virtio.
3. Attach the virtio-win-x.x.x.vfd (i used the one from fedoraproject.org, see below) to you virtual machine
4. Boot up and install the drivers
5. Shutdown, remove the old hard drive image and re-add it as type virtio
6. Boot up and since you already installed the drivers it will boot. Otherwise, you get BSOD..
(You can remove the temp-virtio.img and floppy image).. All done.

For network drivers.. Shutdown, set the “device model” to virtio. Attach the NETKVM-xxxx.iso as a cdrom. Bootup and install drivers. yay!

virtio network drivers, quamranet

http://sourceforge.net/projects/kvm/files/kvm-driver-disc/

virtio block device drivers (aka, hard drive)
http://alt.fedoraproject.org/pub/alt/virtio-win/latest/images/bin/ or

http://sourceforge.net/projects/kvm/files/kvm-guest-drivers-windows/

[] Windows Policy

run gpedit.msc to edit policy

to backup or move to new host, copy the following
%systemroot%\system32\GroupPolicy\Machine and User dirs

to apply changed policy’s
gpupdate /force

[] RDP tricks

SeamlessRDP http://www.cendio.com/seamlessrdp/
rdesktop -A -s “c:\seamlessrdp\seamlessrdpshell.exe c:\program files\internet explorer\iexplore.exe” -u username -p password hostname

 

Error loading stylesheet: A network error occured loading an XSLT stylesheet:
 
 October 28, 2010  Posted by admin at 12:20 pm documentation, Tutorial, vpn , ,  No Responses »

These are the manual instructions for installing and configuring OpenVPN client

See the Section at the end if you are using untangle.

Download openvpn gui at http://openvpn.net/index.php/open-source/downloads.html#latest-stable

Run installer

Leave the components section as default.

Accept the TAP driver install

Right click on OpenVPN GUI and select properties

Go to Compatibility tab and select “run this program as administrator”
(It requires admin priviledges because it needs to write routes for the new VPN tunnel. Without, it will connect but won’t know how to reach the other network.)

Get your OpenVPN configuration files from the system administrator. Copy and paste them into C:\Program Files\OpenVPN\config


ca.crt (certificate authority)
jason.crt (client certificate)
jason.key (client secret key)
jason.ovpn (client configuration). Here are the contents of jason.ovpn:

client
dev tun0
cert jason.crt
key jason.key
ca ca.crt
remote vpn.server 1194

Now you can launch OpenVPN GUI by double clicking the icon on the desktop (the one we just set to run as admin). This will launch the OpenVPN GUI into the system tray.

Click on system tray, right click on OpenVPN GUI, left click “Connect”.

If all goes well, you will successfully connect. The OpenVPN GUI systray icon turns green. Now you are on the Virtual Private Network!

Troubleshooting:

If you can’t connect, double check you have the correct config files in

 

Untangle: Download or Distribute OpenVPN clients

If you happen to be using untangle as the OpenVPN server you can download the untangle openvpn client and configs from the untangle administration web interface. This greatly simplifies your setup as everything is bundled inside the setup.exe. Just download and install and connect.  This requires untangle version 7.4.1 or higher to be compatible with Vista or Win 7. If you are using an older version, click “download a key for all other clients” (see screenshot below) and follow the instructions from the top of this page. If you want more control, you can use the above instructions for new versions of Untangle too.

From untangle web interface:

1. From main Untangle screen. OpenVPN rack, click on Settings
2. Clients Tab
3. Click “Distribute Clients”

4. Then click to download OR enter the email address to send it to.

5. Install on client computer and connect. Everything is done for you..