ssh - chroot 
chroot a user logging in via ssh

apt-get install libpam-chroot

less /usr/share/doc/libpam-chroot/examples/README.example

/usr/share/doc/libpam-chroot/examples/setup-chrootdir-shell.sh

/etc/security/chroot.conf:
+USERNAME   /var/chroot/sshd/home/USERNAME

/etc/pam.d/login:
+session    required   pam_chroot.so


To copy all linked libs (but not libs loaded at runtime) of a programm to our chroot

ldd /usr/bin/pprogram | awk '{if ($3 ~ /^[^ (]/) print $3}' | \
cpio -pdvuL $CHROOTDIR


[ view entry ] ( 497 views )   |  print article
mirror my website 
chmod 700 /etc/cron.daily/websitesync

#!/bin/sh

wget -q --mirror --no-host-directories --cut-dirs=1 --directory-prefix=/var/www \
--user=USERNAME --password=XXXXX ftp://www.holik.at/htdocs

I mirror to my homeserver/var/www and to prevent wget to add
directorynames i use --no-host-directories --cut-dirs=1
without this it would be homeserver/www.holik.at/htdocs/var/www.



[ view entry ] ( 696 views )   |  print article
serial (ttyS) over TCP 
First computer where to redirect serial via TCP:

stty -F /dev/ttyS0 raw 9600 -echo
nc 192.168.0.1 1111 >/dev/ttyS0 </dev/ttyS0

Second computer receiving needs 2 serial's
stty -F /dev/ttyS0 raw 9600 -echo
stty -F /dev/ttyS1 raw 9600 -echo

nc -l -p 1111 >/dev/ttyS1 </dev/ttyS1

Now a programm can connect to /dev/ttyS0 and talks to out first computer.


[ view entry ] ( 1764 views )   |  print article
Internetaccess via adsl 
apt-get install pptp-linux

i got a usb networkcard - to name it adsl i use udev and made /etc/udev/rules.d/local.rules


SUBSYSTEMS=="usb", KERNEL=="eth*", ATTRS{idVendor}=="050d", \
ATTRS{idProduct}=="0121", \
NAME="adsl"

/etc/network/interfaces
auto lo adsl lan dlanusb0 ppp0

iface lo inet loopback

iface adsl inet static
address 10.0.0.140
netmask 255.255.255.0
network 10.0.0.0
broadcast 10.0.0.255
up /etc/network/firewall

iface ppp0 inet ppp
provider adsl_provider

iface lan inet static
address 192.168.0.254
netmask 255.255.255.0
network 192.168.0.0
broadcast 192.168.0.255

iface dlanusb0 inet static
address 192.168.1.254
netmask 255.255.255.0
network 192.168.1.0
broadcast 192.168.1.255

/etc/network/firewall defines table ppp-forward:
iptables -N ppp-forward
iptables -A FORWARD -j ppp-forward

add USERNAME to /etc/ppp/chap-secrets

/etc/ppp/peers/adsl_provider

user USERNAME@PROVIDER
noauth
noipdefault
defaultroute
debug
persist
maxfail 0
holdoff 30
connect "while ! ping -c 1 10.0.0.138>/dev/null; do sleep 5; done "
pty "/usr/sbin/pptp 10.0.0.138 --nolaunchpppd --nobuffer"

/etc/ppp/ip-up.d/firewall

#!/bin/sh

OUTSIDE_DEV=$PPP_IFACE
ADSL_DEV=adsl
INSIDE_DEV=lan
INSIDE_DEV2=dlanusb0
OUTSIDE_IP=$PPP_LOCAL
GOOD_ADDR=192.168.0.0/24
GOOD_ADDR2=192.168.1.0/24

iptables -t nat -A POSTROUTING -s $GOOD_ADDR -o $OUTSIDE_DEV -j SNAT --to $OUTSIDE_IP
iptables -t nat -A POSTROUTING -s $GOOD_ADDR2 -o $OUTSIDE_DEV -j SNAT --to $OUTSIDE_IP
iptables -A ppp-forward -s $GOOD_ADDR -i $INSIDE_DEV -o $OUTSIDE_DEV -j good-bad
iptables -A ppp-forward -s $GOOD_ADDR2 -i $INSIDE_DEV2 -o $OUTSIDE_DEV -j good-bad
iptables -A ppp-forward -i $OUTSIDE_DEV -o $INSIDE_DEV -j bad-good

/etc/ppp/ip-down.d/firewall

#!/bin/sh

OUTSIDE_DEV=$PPP_IFACE
ADSL_DEV=adsl
INSIDE_DEV=lan
INSIDE_DEV2=dlanusb0
OUTSIDE_IP=$PPP_LOCAL
GOOD_ADDR=192.168.0.0/24

iptables -t nat -D POSTROUTING -s $GOOD_ADDR -o $OUTSIDE_DEV -j SNAT --to $OUTSIDE_IP
iptables -D ppp-forward -s $GOOD_ADDR -i $INSIDE_DEV -o $OUTSIDE_DEV -j good-bad
iptables -D ppp-forward -i $OUTSIDE_DEV -o $INSIDE_DEV -j bad-good



[ view entry ] ( 486 views )   |  print article
dnsmasq 
dnsmasq with more than one interface

Read More...

[ view entry ] ( 984 views )   |  print article

<<First <Back | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | Next> Last>>