dinsdag 6 oktober 2009

Command line fu

Hi
these are a list with more complex commands i regularly use with a description of what it does

execute the last command but with sudo priveliges
sudo !!



download the entire site www.example.com as it is presented to an anonymous user using a mozilla browser

wget --random-wait -r -p -e robots=off -U mozilla http://www.example.com





get stats on the network-speed to a host


mtr hostname





twitter from command line (very usefull to keep track of machines)
this twitters the output of the command "uptime"

curl -u mytwitterusername:mypassword -d status="my uptime:`uptime`" http://twitter.com/statuses/update.json


more info here: http://mark.koli.ch/2009/05/howto-tweet-from-the-command-line-with-curl.html

enable passwordless ssh the easy way

ssh-copy-id user@remote-machine



make shift alarm clock

sleep 8h; cat /dev/urandom > /dev/dsp

maandag 5 oktober 2009

Securing a drupal development enviroment

Sometimes After a sync with production our testing site needs to be re-secured (since it's testing we don't want people using it)



install the securesite module

http://drupal.org/project/securesite
obviously you don't need to do this every time if you also install the module on your production enviroment, but switch it off overthere.



Activate the module
on http://yourURL/admin/build/modules

Change the Settings
: http://yourURL/admin/settings/securesite (Force authenticatoin ‘Always’)

That should do it

Props to my good friend Sven

vrijdag 2 oktober 2009

ssh-fu

Ok this is basicly a post were i keep track of some much used ssh commands,
there will probably be things added to this post as time goes by.

use x2x to share keyboard and mouse between 2 computers


Both PC's have to be running X and be logged in
from a shell within X on the PC that has the keyboard and mouse do
 ssh -XC remoteuser@remoteip  x2x -east -to :0.0 




Use SSH tunnel to secure your webtraffic


on the local machine configure firefox to use localhost & port 7070 as a proxy
then log into a shell and execute
ssh -D 7070 username@remote-host




connect over SSH to a computer behind a NAT firewall using a reverse SSH tunnel


on the remote machine (the one behind the firewall) do
ssh -R 19999:localhost:22 sourceuser@138.47.99.99 


Where 19999 can be anny random unused port
138.47.99.99 is the IP of the machine from where you want to access the "remote machine"

now on your server (theone at 138.47.99.99) do

 ssh localhost -p 19999 

and you should log into the machine behind the nat

dinsdag 15 september 2009

automating a drupal backup

automating a drupal backup



hi

I use following script to run a daily backup of several drupal sites




DOW = 'date +%a'
SITE = /var/www
BACKUPLOC = /home/backups/
MYSQLPASS = *******
DBNAME = drupaldb



rm $BACKUPLOC/$DOW.*
tar cf $BACKUPLOC/$DOM.tar $SITE
cd $BACKUPLOC
mysqldump -u root -p $MYSQLPASS $DBNAME > $DOW.dump

woensdag 9 september 2009

ftp backup script

Hi

i've created a ftp backup script a while ago, thought i should start posting stuff here again... seems like a good thingto start with


this scrip will take all the files from the remote site and dump them in a local dir (/home/wouter/temp in this case)


you'll need to remove the space between << and EOF in the first actual line of the script (code tags are not working to well on blogger apperantly)


#!/bin/bash

remote=ftp-site-to-backup
username=your-username
passwd=Password
localdir=/home/wouter/temp
remotedir=/home/wouter/

ftp -ipn << EOF
open $remote
user $username $passwd
lcd $localdir
cd $remotedir
binary
mget gale*
bye
EOF


please take into account that this means the data goes over clear-text and is visible to annyone on the network.



thank you joren from http://www.0110.be for the assistence

dinsdag 13 januari 2009

Fixing Timedrift In debian VM-Ware Virtual machines

Hi All


I had debian server who had 30 sec+ timedrift per minute
As a consequence certain cron jobs where passed over. (cron job scheduled at 17:00 and server jumps from instance from 16:59:47 to 17:00:29, missing the 17:00 slot)

Fixing it ended up being not that hard to actually do. figuring out how to was. Note that You do need a recent kernel that supports clocksource in order to do this.

First off set the ntp for both the host and the vm to the same source by editing the /etp/ntp.conf file



Stop the Virtual Machine
on the host machine search for your VM's .vmx file. Open it in an editor (i use nano)

search for the tools.SyncTime string, it should be set to FALSE, change it to TRUE

Next start up the Virtual Machine again and look for the file /boot/grub/menu.lst

and edit the line for the kernel you boot into
kernel /boot/vmlinuz-2.6.18-5-686 root=/dev/sda1 ro clocksource=pit nosmp noapic nolapic nohz=off


reboot the machine and the time offset should be greatly reduced (a couple of microseconds for me)