Marius van Witzenburg We fight for our survival, we fight!

30Jun/114

How to enable SSH on a Western Digital ShareSpace

Posted by mariusvw

Actually the enabling is quite simple, first log into your ShareSpace and then follow the images below.

You might need this first: How to generate a SSL certificate on your Western Digital ShareSpace drive

Geëtiketeerd als: , , , , 4 Reacties
30Jun/112

How to mount a Western Digital ShareSpace NFS share

Posted by mariusvw

This might become handy if you want to connect the drive on a FreeBSD or Linux machine to easy transfer files to it.

Enable NFS on your Western Digital ShareSpace

Log into your web interface and goto Advanced Mode

Goto the tab Network

Goto Services

Here check the Enable checkbox and add the IP of the machine you want to grant access

Next goto Storage

Edit the share preferences

Enable NFS support for this share

Goto Users

Edit the user preferences

Grand optional write access to this user

Connect to NFS mount of ShareSpace on FreeBSD

List mounts

showmount -e 192.168.2.3

Connect mountpoint

# Read only
mount -t nfs 192.168.2.3:/DataVolume/backup /mnt/
# Read / Write
mount -t nfs -o rw 192.168.2.3:/DataVolume/backup /mnt/

Add share to /etc/fstab

172.16.32.44:/DataVolume/backup /backup nfs rw  2   2

Mount with mount -a

Geëtiketeerd als: , , , , 2 Reacties
30Jun/110

How to backup to a Western Digital ShareSpace drive via SSH-only rsync from FreeBSD

Posted by mariusvw

This manual helps you to backup directories from your server to a Western Digital ShareSpace.

You might need this: How to enable SSH on a Western Digital ShareSpace

Create directories and generate a key for the target

mkdir /usr/data/backup
mkdir /usr/data/backup/keys
ssh-keygen -t rsa -f /usr/data/backup/keys/sharespace
find /usr/data/backup -type f -exec chmod 600 "{}" \; 
find /usr/data/backup -type d -exec chmod 700 "{}" \;

Add public key to the ShareSpace root account

ssh root@<SharespaceIP>
 
cd /root
mkdir .ssh
chmod 700 .ssh
 
# Add key to this file.
vi ssh/authorized_keys
 
chmod 700 .ssh/authorized_keys

Add scripts to server

Place backup.sh in /usr/backup/ and functions.sh in /usr/backup/includes/. Then simply edit to your needs and run with ./backup.sh or from Cron.

backup.sh

#!/bin/bash
# Backup system
# by Marius van Witzenburg <marius@kitara.nl>
# http://kitara.nl
 
mailto="marius@kitara.nl"
mailfrom="noreply@kitara.nl"
 
root="/usr/data/backup"
 
###
# Do not edit below!
###
PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/sbin
pid=$$
 
source $root/include/functions.sh
 
# Create needed directories
test -d $root/files || mkdir $root/files
test -d $root/include || mkdir $root/include
test -d $root/keys || mkdir $root/keys
test -d $root/log || mkdir $root/log
test -d $root/tmp || mkdir $root/tmp
test -d $root/tmp/server || mkdir $root/tmp/server
 
echo $pid > $root/tmp/backup.pid
 
# Sync Public
sync_public "192.168.1.50" "neo" "/usr/data/storage/public" 22
sync_public "192.168.2.50" "trinity" "/usr/data/storage/public" 12345
 
# Sync files to ShareSpace drives
sync_sharespace "192.168.1.50" "neo" "/usr/data/files" "files" 22
sync_sharespace "192.168.1.50" "neo" "/usr/data/music" "music" 22
sync_sharespace "192.168.1.50" "neo" "/usr/data/storage" "storage" 22
sync_sharespace "192.168.2.50" "trinity" "/usr/data/files" "files" 12345
sync_sharespace "192.168.2.50" "trinity" "/usr/data/music" "music" 12345
sync_sharespace "192.168.2.50" "trinity" "/usr/data/storage" "storage" 12345
 
# EOF

includes/functions.sh

#!/bin/bash
 
if [ -z "$root" ]
then
    echo "DO NOT CALL THIS FILE DIRECTLY!"
fi
 
date=`date "+%d-%m-%Y"`
date_reverse=`date "+%Y-%m-%d"`
hostname=`hostname -s`
hostletters=`hostname | sed -E 's/([A-Za-z0-9])[^.]*\.?/\1/g'`
sshport=22
 
# Usage: email "subject" "message"
email() {
    all=$@  
    subject=$1
    message=$2
    echo -e "From: $mailfrom\nTo: $mailto\nSubject: $subject\n\n$message" | /usr/sbin/sendmail -t $mailto 
}
 
# Cleanup loggin and temp directories
cleanup() {
    rm -r $root/log/
    rm -r $root/tmp/
}
 
stop_public() {
    all=$@  
    signal=$1
    name=$2 
    ip=$3   
 
    if [ "$signal" != "finish" ]
    then    
        if [ "$signal" == 'int' ] || [ "$signal" == 'term' ]
        then    
            cleanup 
        fi      
 
        logger -s -p daemon.notice -t 'backup' "stop_public(): Public Sync shutdown!. Target: $name ($ip), Signal: $signal"
        kill $JOB
 
        if [ "$signal" == 'int' ] || [ "$signal" == 'term' ]
        then    
            exit $? 
        else    
            return $?
        fi      
    fi
}
 
# Syntax: sync_public "srv_ip" "srv_name" "source"
sync_public() {
    all=$@  
    srv_ip=$1
    srv_name=$2
    src=$3  
    sshport=$4
 
    # Give it a rest so we don't flood the sshd!
    sleep 3 
 
    key="$root/keys/$srv_name"
 
    #trap "stop_public hub $srv_name $srv_ip" SIGHUP
    trap "stop_public int $srv_name $srv_ip" SIGINT
    trap "stop_public term $srv_name $srv_ip" SIGTERM 
 
    alive=`ssh -ax -q -q -o "BatchMode=yes" -o "ConnectTimeout 15" -i $key -p $sshport root@$srv_ip "echo 0 2>&1" && return 0 || echo 1`
    if [ $alive -eq 0 ] 
    then    
        rsync -e "ssh -ax -i $key -p $sshport" -aWvz --timeout=300 --delete-during $src/ root@$srv_ip:/shares/Public/ >> $root/log/run 2>&1 &
        JOB=$!  
        wait $JOB
 
        tail -2 $root/log/run | logger -p daemon.info -t 'backup'
 
        stop_public finish $srv_name $srv_ip
    else
        logger -s -p daemon.notice -t 'backup' "sync_public(): Connection to $srv_name ($srv_ip) failed..."
    fi
}  
 
stop_sharespace() {
    all=$@
    signal=$1
    name=$2
    ip=$3
    key=$4
 
    if [ "$signal" != "finish" ]
    then
        if [ "$signal" == 'int' ] || [ "$signal" == 'term' ]
        then
            cleanup
        fi
 
        logger -s -p daemon.notice -t 'backup' "stop_sharespace(): ShareSpace backup shutdown!. Target: $name ($ip), Signal: $signal"
        kill $JOB
 
        if [ "$signal" == 'int' ] || [ "$signal" == 'term' ]
        then
            exit $?
        else
            return $?
        fi
    fi
}  
 
sync_sharespace() {
    all=$@
    srv_ip=$1
    srv_name=$2
    src=$3
    target=$4
    sshport=$5
 
    # Give it a rest so we don't flood the sshd!
    sleep 3
 
    key="$root/keys/$srv_name"
 
    #trap "stop_sharespace hub $srv_name $srv_ip $key" SIGHUP
    trap "stop_sharespace int $srv_name $srv_ip $key" SIGINT
    trap "stop_sharespace term $srv_name $srv_ip $key" SIGTERM
 
    alive=`ssh -ax -q -q -o "BatchMode=yes" -o "ConnectTimeout 15" -i $key -p $sshport root@$srv_ip "echo 0 2>&1" && return 0 || echo 1`
    if [ $alive -eq 0 ]
    then
        # Create required directory for server name
        ssh -ax -i $key -p $sshport root@$srv_ip "test -d /shares/backup/$hostname || mkdir /shares/backup/$hostname"
        JOB=$!
        wait $JOB
 
        # Sync data
        logger -p daemon.notice -t 'backup' "sync_sharespace(): Syncing '$src'..."
        rsync -e "ssh -ax -i $key -p $sshport" -rtlDWvp --timeout=300 --chmod=Dug=rwX,Fug=rwX,Do=rX,Fo=r --delete-during $src/ root@$srv_ip:/shares/backup/$hostname/$target/ >> $root/log/run 2>&1 &
        JOB=$!
        wait $JOB
 
        tail -2 $root/log/run | logger -p daemon.info -t 'backup'
 
        stop_sharespace finish $srv_name $srv_ip $key
    else
        logger -s -p daemon.notice -t 'backup' "sync_sharespace(): Connection to $srv_name ($srv_ip) failed..."
    fi
}
 
# EOF
Geëtiketeerd als: , , , , , Geen reacties
30Jun/110

How to solve the problem that a bluetooth device not always auto connects

Posted by mariusvw

I have been irritating me about my mouse not connecting when I turned it on, the problem seems to be solved by adding the device as a favorite in the bluetooth settings.

First goto System Preferences:

Path:  » System Preferences...

Then goto the Bluetooth panel

Path:  » System Preferences... » Bluetooth

Select your device and click the gear at the bottom, there click Add to favorites.

This was my solution :-)

26Jun/110

How to configure a automatically native IPv6 connection on FreeBSD

Posted by mariusvw

First you need to install a DHCP client

cd /usr/ports/net/dhcp6
make install clean

Setup config for dhcp6c

cp /usr/local/etc/dhcp6c.conf.sample /usr/local/etc/dhcp6c.conf
vi /usr/local/etc/dhcp6c.conf

Add the following

interface em0 {
    send ia-pd 0;
};
 
id-assoc pd {
    prefix-interface em0 {
        sla-id 1;
    };
};

Add the following to /etc/rc.conf

ipv6_enable="YES"
ipv6_network_interfaces="em0"
ipv6_defaultrouter="fe80::%em0"
dhcp6c_enable="YES"
dhcp6c_interfaces="em0"

Run the IPv6 startup script.

/etc/rc.d/network_ipv6 restart

Now startup the client

/usr/local/etc/rc.d/dhcp6c start

To test the connection you should be able to ping XS4ALL.

ping6 xs4all.nl

You also might want to check out these posts for some more information:
How to use a PPPoE or PPPoA connection of XS4ALL on FreeBSD

How to configure IPv6 DHCP client for XS4ALL on FreeBSD

How to configure a IPv6 gateway for XS4ALL on FreeBSD

Geëtiketeerd als: , , , , Geen reacties
26Jun/111

How to configure a manual native IPv6 connection on FreeBSD

Posted by mariusvw

Configuring a native IPv6 connection on FreeBSD with an already established connection on a router in the network is quite simple.

Add the following to /etc/rc.conf

# IPv6 (2001:1234:1234::/48)
ipv6_enable="YES"
ipv6_network_interfaces="em0"
ipv6_ifconfig_em0="2001:1234:1234:1::666 prefixlen 64"
ipv6_defaultrouter="2001:1234:1234:1::"

Run the IPv6 startup script.

/etc/rc.d/network_ipv6 restart

To test the connection you should be able to ping XS4ALL.

ping6 xs4all.nl

You also might want to check out these posts for some more information:
How to use a PPPoE or PPPoA connection of XS4ALL on FreeBSD

How to configure IPv6 DHCP client for XS4ALL on FreeBSD

How to configure a IPv6 gateway for XS4ALL on FreeBSD

Geëtiketeerd als: , , , 1 Reactie
24Jun/110

How to relocate repository root URL of your Subversion working copy

Posted by mariusvw

Ever had this issue a administrator changed the location of the repository?

Well, I had ;-)

Relocating the URL of the repository is quite simple with svn switch --relocate, here you have some simple steps to fix your working copy.

1. Go into the current working copy.

cd /path/to/your/working/copy

2. Get the current repository root URL.

svn info

3. Now switch the old repository root to the new repository root.

svn switch --relocate http://old_repository_root http://new_repository_root

4. Optionally you can verify if the relocate went successful.

svn info
22Jun/111

How to make a VPN connection with Mac OS X on your iMac or Macbook (pro) to a FRITZ!Box

Posted by mariusvw

If you need some more info on how to configure your FRITZ!Box check out How to configure VPN on your FRITZ!Box 7340.

Configure your iMac or Macbook (Pro) to use VPN to your FRITZ!Box router VPN service.

First add a new VPN config by clicking the plus at the left bottom.

Next is to select Cisco IPsec and fill out a name at the Service Name field. This can be something like Home VPN.

Next is to fill out the VPN information in this configuration.

  • Server Address: add the IP or Host of your FRITZ!Box WAN connection.
  • Account Name: add YOUR_USERNAME.
  • Password: add YOUR_PASSWORD.

Click Authentication Settings and fill out the following.

  • Shared Secret: YOUR_SHARED_PASSWORD.
  • Group Name: add YOUR_MAIL_ADDRESS.

Geëtiketeerd als: , , , , , , , 1 Reactie
22Jun/110

How to make a VPN connection with iOS on your iPod or iPhone to a FRITZ!Box

Posted by mariusvw

If you need some more info on how to configure your FRITZ!Box check out How to configure VPN on your FRITZ!Box 7340.

Configure your iPod or iPhone to use VPN to your FRITZ!Box router VPN.

Goto the "Settings" of your iPod or iPhone and then goto "General".

Goto "Network".

Goto "VPN".

Goto "Add VPN Configuration...".

Fill out the screen below...

  • 1. add your own fancy description.
  • 2. add the IP or Host of your FRITZ!Box WAN connection.
  • 3. add YOUR_USERNAME.
  • 4. add YOUR_MAIL_ADDRESS.
  • 5. add YOUR_SHARED_PASSWORD.

To setup a FRITZ!Box router check out the following, it might help you getting started.

How to configure VPN on your FRITZ!Box 7340

Geëtiketeerd als: , , , , , , , Geen reacties
22Jun/110

How to configure VPN on your FRITZ!Box 7340

Posted by mariusvw

FRITZ!Box

Setup the VPN settings on the FRITZ!Box with a VPN config file.

Save the content below to a file named vpn.cfg

vpncfg {
        connections {
                enabled = yes;
                conn_type = conntype_user;
                name = "YOUR_MAIL_ADDRESS";
                always_renew = no;
                reject_not_encrypted = no;
                dont_filter_netbios = yes;
                localip = 0.0.0.0;
                local_virtualip = 0.0.0.0;
                remoteip = 0.0.0.0;
                remote_virtualip = VPN_CLIENT_IP;
                remoteid {
                        key_id = "YOUR_MAIL_ADDRESS";
                }
                mode = phase1_mode_aggressive;
                phase1ss = "all/all/all";
                keytype = connkeytype_pre_shared;
                key = "YOUR_SHARED_PASSWORD";
                cert_do_server_auth = no;
                use_nat_t = yes;
                use_xauth = yes;
                use_cfgmode = no;
                xauth {
                        valid = yes;
                        username = "YOUR_USERNAME";
                        passwd = "YOUR_PASSWORD";
                }
                phase2localid {
                        ipnet {
                                ipaddr = 0.0.0.0;
                                mask = 0.0.0.0;
                        }
                }
                phase2remoteid {
                        ipaddr = VPN_CLIENT_IP;
                }
                phase2ss = "esp-all-all/ah-none/comp-all/no-pfs";
                accesslist = "permit ip any VPN_CLIENT_IP 255.255.255.255";
        }
        ike_forward_rules = "udp 0.0.0.0:500 0.0.0.0:500", "udp 0.0.0.0:4500 0.0.0.0:4500";
}

Replace the below values with the right settings for your network, I'll describe it with the default router values.

  • YOUR_MAIL_ADDRESS, replace this with your mail address.
  • VPN_CLIENT_IP, replace this with something like 192.168.178.201.
  • YOUR_SHARED_PASSWORD, replace this with your own preferred shared password.
  • YOUR_USERNAME, replace this with your VPN username, use [a-z] only.
  • YOUR_PASSWORD, replace this with your VPN password, mind quote signs!

This configuration has been tested on iOS and Mac OS X, check the manuals below to configure your client.

Page 1 of 71234567