Saturday, June 28, 2008

Transfer Files Automatically

I had to backup the svn server and database (both running on Ubuntu) on our backup machine every day. It was painful enough that I decided to write a shell script to do it automatically. This might be the case for you as well.

Here is a Shell Script which backs up a folder on one machine by compressing and transferring it to another machine via ssh.

In order to back on a regular basis you may configure some fields in the shell script and place it in one of /etc/cron.* directories in Linux.

To configure the shell script you should set up these parameters:

FILE_NAME: File name to be backed up

TEMP_DIR: Directory for temporarily copying

DEFLATION: Whether to compress the file or not

EXTRACT: Whether to extract the file in destination

SRC_DIRs: Source Directory(s) to be backed up

DEST_DIR: Destination Directory

SRC_IP: Source machine IP Address use 127.0.0.1 for localhost

DEST_IP: Destination machine IP Address use 127.0.0.1 for localhost

SRC_USER: Source machine user

DEST_USER: Destination machine user

If the source and the destination machines were different, which usually are, the source machine should be able to connect to destination via ssh with no password. So you have to make them transparent to each other. this is a onetime process. For more convenience I've written a shell script named transparent-ssh which does the entire process.

Download the script and run this command on the source machine:

./transparent-ssh.sh [user] [destination-machine-ip]

It takes the remote machine username and IP address as arguments and installs your public key on the remote machine. The remote machine must accept password authentication or one of the other keys in your ssh-agent.

If you've already generated your public key once, just try the command with “-c” (copy only) parameter which only copies your public key to remote machine.

Tuesday, March 11, 2008

A Quick guide to set up a Linux Gateway

This document helps you to set up a small Linux based gateway as quick as possible.

run the following commands on the gateway machine:

switch into root user

1: user$ sudo -i  

Enable packet forwarding by kernel

2: root$ echo 1 > /proc/sys/net/ipv4/ip_forward   

exit root user

3: root$ exit

append the forwarding rule:

4: user$ iptables -A FORWARD -i eth0 [-s, --source [!] address[/mask]] -o ppp0 -j ACCEPT

e.g: user$ iptables -A FORWARD -i eth0 -s 192.168.1.45 -o ppp0 -j ACCEPT

altering the packets as they are about to go out

5: user$ sudo iptables -t nat -A POSTROUTING -o ppp0 -j MASQUERADE

and finally set gateway on the client machine, if you are running on Linux you can do it simply by executing this command:

user$ sudo route add default gw   

to configure more complicated gateway you can refer to :

http://newbiedoc.sourceforge.net/networking/homegateway.html

http://www.yolinux.com/TUTORIALS/LinuxTutorialIptablesNetworkGateway.html

Sunday, December 16, 2007

Dell Conexant Modem Driver for Linux(Debian, Redhat)

Dell has released a version of HSF Modem Driver for linux that is fully compatible with dell laptops.

You can download the driver here .

But if you upgrade an Ubuntu 7.04 installation to Ubuntu 7.10, your modem will no longer work.

But take it easy download the new driver hsfmodem_7.60.00.18oem_i386.deb, which has been tested and qualified for Ubuntu 7.10. If you upgraded from Ubuntu 7.04, uninstall the linux-backports-modules package or the driver will not work; linux-backports-modules was installed in Ubuntu 7.04 to provide a fix for a different issue and is not required in Ubuntu 7.10.

  • NOTE: After installing the modem driver, you might get a pop-up window telling you that the Volume Control has quit unexpectedly and asks you to reload (or not reload) the panel. Click on Reload. Afterwards, the sound icon on the top right corner of the screen changes to “mute”, but sound should be OK. A logout/login or GDM restart clears the issue. This issue happens because the modem driver lays down its own set of sound codecs and unloads the snd-hda-intel module during the installation process.

Saturday, December 15, 2007

Solution to FTP Upload Problem with ISA Server 2004

As a new user of ISA, I had a very annoying problem. I was unable to upload any file from my new website using FTP. I kept getting Error 550, Access denied. every time I tried to create a new folder or upload a file using SFTP or FTP.

Finally, it turns out that ISA Server 2004 has an option to restrict FTP uploads. Unfortunately this option has been set for both directions (FTP sessions initiated from both inside and outside the internal network).

To find that (somehow hidden) option that enables the restriction was another issue. Here is how to fix it:

1. In the console tree of ISA Server Management, click Firewall Policy.
Where?

Microsoft Internet Security and Acceleration Server 2004
Server_Name
Firewall Policy
2. In the details pane, click a server publishing rule or access rule that applies to FTP traffic.
3. On the Tasks tab, click Edit Selected Rule.
4. On the Traffic tab (for a server publishing rule) or on the Protocols tab (for an access rule), click Filtering, and then click Configure FTP.
5. On the Protocol tab, select Read Only, if FTP uploads should be blocked. Otherwise make sure the checkmark is removed(
FTP filtering is set to Read-only by default!).