usb modem dialin 
Server

needed packages: mgetty, pppd

start and stop mgetty on plugin of usbmodem (0572:1329 Conexant Systems (Rockwell), Inc.)

/etc/init/mgetty.conf
# mgetty - dialin daemon

description "mgetty daemon"

start on tty-device-added KERNEL=ttyACM0
stop on tty-device-removed KERNEL=ttyACM0

respawn
exec /sbin/mgetty -s 115200 -D /dev/ttyACM0

/etc/mgetty/login.config
/AutoPPP/ - a_ppp /usr/sbin/pppd auth +chap -pap name dialinserver remotename dialer debug

I use chap instead of pap because of plain password used by pap.

/etc/ppp/chap-secrets
dialer dialinserver password *

/etc/ppp/options.ttyACM0
10.0.0.1:10.0.0.2


Client

needed packages: pppd

/etc/ppp/peers/dialinserver
noauth
connect "/usr/sbin/chat -v -f /etc/chatscripts/dialinserver"
debug
/dev/ttyS0
115200
defaultroute
noipdefault
name dialer
remotename dialinserver

/etc/chatscripts/dialinserver
ABORT BUSY ABORT 'NO CARRIER' ABORT VOICE ABORT 'NO DIALTONE' ABORT 'NO DIAL TONE'
ABORT 'NO ANSWER' ABORT DELAYED
'' ATZ
OK-AT-OK "ATDTnumber"
CONNECT \d\c

/etc/ppp/chap-secrets
dialer dialinserver password *

Connect with "pon dialinserver" and disconnect with "poff dialinserver"

[ view entry ] ( 1039 views )   |  print article
bluetooth network with bluez4 and udev 
Many things changed for bluez4. Now everything is made through dbus commands.

apt-get install bluetooth bluez (on server and client)

First check for bdaddr on server and client:

Server:> hcitool dev
Devices:
hci0 00:01:1A:63:49:33

Client:> hcitool dev
Devices:
hci0 00:02:6E:53:42:78

Pairing:

Server:> /usr/share/doc/bluez/examples/test-adapter discoverable on
Server:> /usr/share/doc/bluez/examples/simple-agent

Client:> /usr/share/doc/bluez/examples/simple-agent 00:02:6E:53:42:78 00:01:1A:63:49:33

Hint: On newer systems use /usr/bin/bluez-test-adapter, /usr/bin/bluez-simple-agent and bluez-test-network

On Server:
Agent registered
RequestPinCode (/org/bluez/25897/hci0/dev_00_02_6E_53_42_78)
Enter PIN Code: 1234
(keep simple-agent running)

On Client:
RequestPinCode (/org/bluez/4078/hci0/dev_00_01_1A_63_49_33)
Enter PIN Code: 1234
Release
New device (/org/bluez/4078/hci0/dev_00_01_1A_63_49_33)

Pairing keys are stored hashed in /var/lib/bluetooth/<local bdaddr>/linkkeys

Network:
--- /usr/share/doc/bluez/examples/test-network
+++ /usr/share/doc/bluez/examples/test-network.sh
@@ -35,9 +35,10 @@
print "Press CTRL-C to disconnect"

try:
- time.sleep(1000)
- print "Terminating connection"
+ while 1:
+ time.sleep(1000)
except:
pass

+print "Terminating connection"
network.Disconnect()
Client:> /usr/share/doc/bluez/examples/test-network.sh 00:01:1A:63:49:33
(keep test-network running)

On Server:
Authorize (/org/bluez/25897/hci0/dev_00_02_6E_53_42_78, 0000000f-0000-1000-8000-00803f9b24fa)
Authorize connection (yes/no): yes

Now you can stop simple-agent.

Server:> ifconfig ifconfig bnep0 192.168.0.1 netmask 255.255.255.0 up
Client:> ifconfig ifconfig bnep0 192.168.0.2 netmask 255.255.255.0 up

Now you can ping each other.

To avoid start simple-agent on server for connection authorisation each time you can trust the client with:

Server:> /usr/share/doc/bluez/examples/test-device trusted 00:01:1A:63:49:33 on

Automatisation:

On my server i'm running a bridged network with dhcp support, therefore i use udev to add bnep to my bridge:

/etc/udev/rules.d/local.rules:
ACTION=="add", SUBSYSTEM=="net", KERNEL=="bnep?*", PROGRAM="/usr/sbin/brctl addif br0 %k"

Client:

/etc/udev/rules.d/local.rules:
ACTION=="add", SUBSYSTEM=="net", KERNEL=="bnep?*", PROGRAM="/sbin/dhclient -nw -pf /var/run/dhclient-%k.pid %k"
ACTION=="remove", SUBSYSTEM=="net", KERNEL=="bnep?*", PROGRAM="/usr/bin/pkill -9 dhclient"

maybe you need to reload udev!

On clientside you only have to keep running
/usr/share/doc/bluez/examples/test-network.sh 00:01:1A:63:49:33

Usually this should be done by networkmanager but this is not supported (now)

[ view entry ] ( 2632 views )   |  print article
dnstunnel with iodine and bind9 
Iodine server with public IP:

#> apt-get install iodine

For "good" connection i used a mtu of 256 through my provider DNS.
On local network no mtu change was necessary.

/etc/default/iodine
START_IODINED="true"
IODINED_ARGS="-m 256 -l IODINE_SERVER_IP 10.0.0.1 tunnel.DOMAIN"
IODINED_PASSWORD="mypassword"
#> sysctl -e net.ipv4.ip_forward=1
#> iptables -t nat -A POSTROUTING -s 10.0.0.0/255.255.255.0 -o eth0 -j MASQUERADE

Bind9 server:

zonesfile:
zone "DOMAIN" in {
type master;
file "/etc/bind/zones/DOMAIN";
allow-query { any; };
};

zone "tunnel.DOMAIN" in {
type forward;
forward only;
forwarders {
IODINE_SERVER_IP;
};
};
zonefile:
tunnel      1D   IN   NS    tunnelhost
tunnelhost 1D IN A IODINE_SERVER_IP

Client:

#> apt-get install iodine
#> iodine -m 256 -P mypassword tunnel.DOMAIN
#> route add default gw 10.0.0.1


Well it seams that my provider drop's packets with some payload in it:

#> ping -c1 -s 109 10.0.0.1 fails

but

#> ping -c1 -s 109 -p ff 10.0.0.1 succeeds


[ view entry ] ( 1441 views )   |  print article
chrooted sftp only 
useradd -s /bin/false -m SFTPUSER
mkdir /home/SFTPUSER/.ssh
ssh-keygen -t rsa -b 2048 -N '' -f /home/SFTPUSER/.ssh/id_rsa
chown -R SFTPUSER:SFTPUSER /home/SFTPUSER/.ssh
chmod 600 /home/SFTPUSER/.ssh/id_rsa

/etc/ssh/sshd_config:
Subsystem       sftp    internal-sftp

Match user SFTPUSER
PasswordAuthentication no
AllowTcpForwarding no
X11Forwarding no
ForceCommand internal-sftp
ChrootDirectory /chroot
chown root:root /chroot
mkdir /chroot/SFTPUSERDIR
chown SFTPUSER:SFTPUSER /chroot/SFTPUSERDIR

echo "put FILENAME" | \
sftp -oIdentityFile=/home/SFTPUSER/.ssh/id_rsa \
-oTCPKeepAlive=no -oServerAliveInterval=15 \
SFTPUSER@localhost:SFTPUSERDIR


[ view entry ] ( 2469 views )   |  print article
secure rsync to only one directory 
I want to rsync to a remote host to a given directory.

local-host:
ssh-keygen -t rsa
keyfilename: ~/.ssh/rsync
ssh-copy-id -i .ssh/rsync rsyncuser@remote-host

rsync files with ssh:
rsync -vaHxr --delete \
-e "ssh -i ~/.ssh/rsync -c arcfour -o Compression=no -x" \
LOCALDIR rsyncuser@remote-host:

remote-host

/home/rsyncuser/.ssh/authorized_keys:
from="192.168.0.2,",command="/home/rsyncuser/validate-rsync.sh",
no-pty,no-agent-forwarding,no-port-forwarding
ssh-dss 012345678...
limit access with from (optional).
On sucessfully ssh login command is executed.
Read More...

[ view entry ] ( 2487 views )   |  print article

<<First <Back | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | Next> Last>>