martedì 24 gennaio 2012

UBUNTU 10.04 - Hiding users at grafic login screen

I had a problem since I created some additional users for particular tasks but I didnt want they were shown in the login screen.
Edit this file

fem@rodizio:~$ sudo vi /etc/gdm/custom.conf


adding this lines

[greeter]
Exclude=user1,user2,user3,nobody

where user1, user2 and user3 are users to hide at login screen; nobody must be added otherwise it will be shown.
Then reboot..

lunedì 23 gennaio 2012

SOCKS5 Proxy for secure browsing

If you use to connect from open access internet points and you have a valid account on a SSH server , in my case I can use a simple modified router a Pirelli AGA (mounting linux and a valid SSH server) to do so.

From the shell of the client

fem@rodizio:~$ ssh USER_SERVERSSH@SERVERSSH -p 1022 -D 2100

"-p 1022" since my ssh service listen on this port (the default one is 22)
"-D 2100" tells the SSH client (localhost) to listen at this port to listen our browser requests.

We have only to go on browser settings (ie, opera, firefox ,chrome etc) and indicate that we use a socks5 proxy indicating as ip "localhost" and as port "2100"

that's all

OPENWRT - Reverse tunnel with SSH

I want to reach a router that is connected to the net using like gateway a USB dongle, the problem is that my network provider use a NAT that doesn't allow to reach the dongle with a public ip.
The solution is a "reverse tunnel" (in this case with SSH) that is initiate from the remote host we want to reach (the OpenWRT router) to a SSH server that in my case is an Ubuntu 10.04 box.
OPENWRT use as SSH client dropbear, a lightweight version that is compatible with public key authentication of the standard openSSH.


Generate a valid public key on the OpenWRT router with dropbear in .ssh folder . NO PUBLIC KEY FILES HAVE TO BE INSIDE THIS FOLDER OTHERWISE DROPBEARKEY WILL GENERATE AN ERROR!!

root@OpenWrt:~/.ssh# cd /root/.ssh/
root@OpenWrt:~/.ssh# dropbearkey -t rsa -f id_rsa


The output shold be something like that

root@OpenWrt:~/.ssh# dropbearkey -t rsa -f id_rsa
Will output 1024 bit rsa secret key to 'id_rsa'
Generating key, this may take a while...
Public key portion is:
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAAgwCZfO3SRHCmekstO+tLRS4Yj3a0/8tCeWgXbQLI+3dv+wqZKS1wfOlLviRA9yj124CoAAAAB3NzaC1yc2EAAAADAQABAAAAgwCZfO3SRHCmekstO+tLRS4Yj3a0/8tCeWgXbQLI+3dv+wqZKS1wfOlLviRA9yj124Co
V6GRZbzPmJ+b root@OpenWrt
Fingerprint: md5 ac:a4:aa:f8:a2:a7:e8:ae:b9:ad:aa:2e:a4:eb:a0:a7


Copy the string of the generated public key in authorized_keys in the .ssh folder of the SSH server (ssh-rsa ..... root@OpenWrt) , I used scp command but you can do it in every way , by hand for example.


root@OpenWrt:~/.ssh# cd /root/.ssh/
root@OpenWrt:~/.ssh# scp -P 1022 authorized_keys USER_SERVER@SERVERSSH:/home/USER_SERVER/.ssh/

Now it should be possible to authenticate with the public key and without password

Note that this 2 commands are equivalent with the dropbear client

root@OpenWrt:~/.ssh# dbclient -i ~/.ssh/id_rsa -y -p 1022 USER_SERVER@SERVERSSH #equivalent to
root@OpenWrt:~/.ssh# ssh -i ~/.ssh/id_rsa -y -p 1022 USER_SERVER@SERVERSSH


This is the command to make the tunnel ssh run in background (this is necessary if you want to put it in a script)


/usr/bin/dbclient -f -N -R 1500:localhost:22 -p 1022 USER_SERVER@SERVERSSH -i /root/.ssh/id_rsa -y


Now logging in the SSH server shell with this command we will be able to reach the OpenWRT shell using port 1500 of the SSH server and using the tunnel we have create.


USER_SERVER@SERVERSSH:~/ssh root@localhost -p 1500

SSH automatic authentication without inserting password

We start with 2 ubuntu box's 10.04 , one is the server (SERVER_SSH) the other is the client (CLIENT_SSH).
Both box's have not .ssh folder in their home directory.

On the CLIENT_SSH:
make .ssh folder in the home directory

user@CLIENT_SSH:~$ mkdir ~/.ssh

generating id_rsa.pub public key

user@CLIENT_SSH:~$ cd ~/.ssh
user@CLIENT_SSH:~$ ssh-keygen -t rsa

copying content of id_rsa.pub in the authorized_keys file using cat command (can do it also by hand copying and pasting)

user@CLIENT_SSH:~$ cd ~/.ssh
user@CLIENT_SSH:~$ cat ~/.ssh/id_rsa.pub >> authorized_keys

add the ssh client

user@CLIENT_SSH:~$ssh-add




On the SERVER_SSH:

make sure the /etc/ssh/sshd_config file allow this kind of authentication

otheruser@SERVER_SSH:~$ vi /etc/ssh/sshd_config

the following parameters must be set on 'yes'

RSAAuthentication yes
PubkeyAuthentication yes


make .ssh folder in the home directory

otheruser@SERVER_SSH:~$ mkdir ~/.ssh

copying the client authorized_keys file to the server (-P 1022 its only for me since the ssh service is listening on this port, otherwise put 22 here)

restarting ssh server

otheruser@SERVER_SSH:~$ /etc/init.d/ssh restart

Now, should be possible authentication without inserting password at prompt.

sabato 21 gennaio 2012

Blocking websites on OpenWRT

If you have an openwrt router that is your gateway and you dont want to let users access some websites, you must edit the file dnsmasq.conf:


root@OpenWrt:~# vi /etc/dnsmasq.conf


adding this line:


#### Blocked website internet.tre.it ####
address=/internet.tre.it/127.0.0.1


then restarting dnsmasq service


root@OpenWrt:~# /etc/init.d/dnsmasq restart


that's all.

venerdì 4 novembre 2011

Testare velocità cavo lan con Ubuntu

Se non vi interessa la premessa saltate all' asterisco ***
In questi giorni ho cablato un locale ( ho finito 300m di cavo e non mi è nemmeno bastato !!)
A parte passare il cavo nei corrugati ho anche dovuto imparare a crimpare le 2 estremità del cavo con i classici plug.
Il cavo utilizzato è un cat5e, non di qualità eccelsa, comunque sembra funzionale allo scopo.
Oggi sono andato a testare che i cavi funzionassero e mi è venuta la voglia di misurare anche la velocità massima trasferibile. Ricordo che i cat5e sono già gigabit quindi in teoria potrei raggiungere i 1000mbit/s (wow!).
Purtroppo la velocità reale è un po diversa visto che esistono i router, le schede di rete 100mbit/s e mille altri colli di bottiglia.
Ho pensato, dopo aver messo un router tra i 2 pc che dovevano trasmettersi un file di prova, che quello non era il migliore modo per testare il cavo in se per se.
Perchè ? Perchè il router che avevo io , di qualità media , non mi faceva andare a più di 5,5 mb/s quindi 44mbit/s.... insoddisfacente per la mia gigabit lan.
Allora ho tolto il router facendo un aggiunta al cavo da testare con un cavo crossover per realizzare un link diretto tra i 2 pc.
Per la cronaca un cavo crossover è un cavo lan con ad una estremità un plug crimpato in standard 568a e dall' altra 568b.
E,ancora per la cronaca :ora come ora, con 2 pc non preistorici si puó fare il link diretto con un cavo dritto (568b o 568a su entrambe le estremità) visto che le schede di rete moderne sono "autosensing",
Con il link diretto la velocità è salità a circa 8mb/s circa 64mbit/s.... un pó meglio ma ancora bassa.
Il problema sta nella velocità dei dischi rigidi, di uno dei due portatili (10 anni di vita).
Così tornato a casa ho deciso di testare la velocità di trasferimento tra 2 pc con scheda di rete gigabit e disco rigido sata, risultato 55mb/s quindi 440mbit/s .... cominciamo a ragionare !
Quindi ho capito che ci voleva qualcosa di "più tecnico" per testare questi cavi, visto che i colli di bottiglia sono ovunque trasferendo grezzamente un file tra 2 pc.
***
Cercando su google (cosa di cui sono malato) ho trovato un programmino microscopico da terminale per linux chiamato iperf
sudo apt-get install iperf

da installare su entrambi i pc.
Poi si da su un pc che fungerà da server
iperf -s

e sull' altro
iperf -c 192.168.1.10


Sostituite 192.168.1.10 con l' ip del pc che fa da server.
Il programma fa il test (pochi secondi)e vi da il risultato.
Nel mio caso per i cavi patch sia crossover che dritti di 1.5 metri circa mi da come velocità max 961mbit/s.......ok siamo vicini al gigabit.
Ora non mi resta che testarlo sui cavi che ho realizzato..... vi faró sapere.
Saluti


- Posted using BlogPress from my iPhone

lunedì 8 marzo 2010





Installare OpenWrt su router Huawei D100

Da qualche giorno il continuo cambio di firmware di varie compagnie sul mio D100 non mi soddisfaceva più....così siamo passati a qualcosa di più interessante, ovvero OpenWrt.
Questo router, basato su chipset Broadcom BCM5354, era già basato su una versione modificata di Busybox (Linux quindi) ma con diverse limitazioni.
Avevo trovato una wiki dello scorso anno dove veniva descritta la procedura per caricare OpenWrt ma non ci avevo capito molto e soprattutto dovevo smontare il router e invalidare la garanzia.


Ok, vi dico subito che bisogna utilizzare un interfaccia seriale per dialogare col router e interrompere il boot del sistema per permetterci di caricare il nuovo firmware, quindi armatevi di pazienza smontate il router con cautela (sono solo 2 viti) e apritelo.
Io ho usato un interfaccia usb seriale ricavata dal cavo usb di un telefonino (mi sembra fosse un Sagem) dovrebbe essere equivalente a quelle ricavate dal cavo dei Nokia (DKU-5). Questi cavi non hanno bisogno di essere alimentati dalla piastra madre del router ma si alimentano direttamente dalla USB a cui sono collegati.
Per capire quali sono i cavi che ci interessano io ho proceduto cosi:
ho cercato il gnd (massa) con un tester, poi con il cavo inserito nella USB, i driver caricati ho aperto Hyperterminal e ho cortociruitato a 2 a 2 i vari cavi provando a vedere se avevo un ritorno sulla console digitando qualcosa, facendo così ho trovato txd(trasmissione) e rxd(ricezione); per capire quale dei 2 è il rxd basta toccarlo con un dito con Hyperterminal aperto, quello che genera strani caratteri è il rxd, ovvero quello che riceve.

Prima di collegare tutto controllate che l' interfaccia seriale funzioni correttamente: provate a cortocircuitare i contatti txd e rxd e digitando qualche carattere dovreste vedere l' output in consolle.


A questo punto bisogna collegare i contatti txd, rxd e gnd ai rispettivi txd,rxd e gnd della seriale (rispettate lo schema qui sotto):

Modem txd <--> rxd Seriale
Modem rxd <--> txd Seriale
Modem gnd <--> gnd Seriale

Ok, una volta collegato settiamo l' interfaccia seriale così (io ho usato Hyperterminal, ma va bene Putty o qualsiasi altro programma analogo):

Velocità :115200 Bdps
Data bits : 8
Parity: None
Stop bits: 1
Flow Control: None



Ok, a questo punto se avete fatto bene i collegamenti connettendo Hyperterminal e avviando i router dovreste vedere tutta la sequenza di boot tipo questa:

CFE version 1.0.37 for BCM947XX (32bit,SP,LE)
Build Date: Èý 7ÔÂ 22 12:16:58 CST 2009 (bcm@old_server.com)
Copyright (C) 2000,2001,2002,2003 Broadcom Corporation.

Initializing Arena
Initializing Devices.
Boot partition size = 262144(0x40000)
et0: Broadcom BCM47xx 10/100 Mbps Ethernet Controller
CFE reboot flag0 = 0x12345678, flag1 = 0x0,flag2 = 0xffffffff,reboot_number = 0x
3
CPU type 0x29029: 240MHz
Total memory: 32768 KBytes


Per poter caricare il nuovo firmware dovete spegnere il router, e tenendo premuto ctrl-c nella consolle della seriale e accenderlo e trovere il prompt della CFE:

CFE>


Questo è il file da inviare in formato TRX che ho utilizzato : openwrt-brcm-2.4-squashfs.trx


A questo punto possiamo caricare OpenWrt in formato TRX andandolo a prelevare tramite tftp (quindi dovete settare un server tftp funzionante ed avere indirizzi statici su router e server tftp), io ho usato tftp per Windows (programma microscopico...)
Ovviamente cambiate 192.168.1.33 con l' indirizzo della macchina dove avete avviato il server tftp.


CFE> flash -noheader 192.168.1.33:/openwrt-brcm-2.4-squashfs.trx flash1.trx

Programming…done. 3215360 bytes written *** command status = 0

Ok, ora riavviamo il router e godiamoci (si fa per dire) il nostro OpenWrt installato.

CFE> reboot


Appena installato tutto la LAN non funzionava impedendomi di comandare il router via ssh, tramite la porta seriale ho editato il file /etc/config/network in questo modo:

root@OpenWrt:~# cat /etc/config/network
#### VLAN configuration

config switch eth0

option vlan0 "0 5"

#option vlan1 "1 2 3 4 5*"


#### Loopback configuration

config interface loopback

option ifname "lo"

option proto static

option ipaddr 127.0.0.1

option netmask 255.0.0.0


#### LAN configuration

config interface lan

option type bridge

option ifname "eth0.0"

option proto static

option ipaddr 192.168.1.12

option netmask 255.255.255.0

option gateway 192.168.1.1

option dns 192.168.1.1


#### 3G/UMTS configuration

config interface wan

option ifname 'ppp0'

option proto '3g'

option device '/dev/usb/tts/0'

option apn 'internet'
root@OpenWrt:~#

Così sono riuscito a pingare le macchine che avevo intorno e pingare il router, quindi aprendo la pagina web sono riuscito ad accedere finalmente a OpenWrt in tutta la sua versatilità.

Ciao, alla prossima.