apt-listbugs

Yesterday night I’ve updated my “Frankenstein” (Linux Mind Debian Edition) to a shiny, new, pure Debian Sid.

Not considering the tuning and the installation of needed packages and the backup restore, it had take about 1hr with the businesscard iso. Now I’m ready to explore the “Unstable” branch of Debian with my new tool: apt-listbugs.

After installing it (with apt-get, obviously), he waits in the background for an apt-get install or upgrade command, ready to warn you about what you’re doing. It basically lists you bugs in unstable before you install the buggy package.

An example!

I’ve searched on this page a package with some serious bug, and then I’ve tried to install it to see if apt-listbugs should had worked. My choose was a package named bison


fixed@gauss:~$ apt-cache show bison
Package: bison
Version: 1:2.5.dfsg-2.1
Installed-Size: 1833
Maintainer: Chuan-kai Lin <cklin@debian.org>
Architecture: i386
Depends: m4, libc6 (>= 2.4), libbison-dev (= 1:2.5.dfsg-2.1)
Suggests: bison-doc
Description: YACC-compatible parser generator
 Bison is a general-purpose parser generator that converts a
 grammar description for an LALR(1) context-free grammar into a C
 program to parse that grammar.  Once you are proficient with Bison, you
 may use it to develop a wide range of language parsers, from those used
 in simple desk calculators to complex programming languages.
 .
 Bison is upward compatible with Yacc: all properly-written Yacc
 grammars ought to work with Bison with no change.  Anyone familiar with
 Yacc should be able to use Bison with little trouble.  Documentation of
 the program is in the bison-doc package.
Multi-Arch: foreign
Homepage: http://www.gnu.org/software/bison/
Tag: devel::{code-generator,lang:c,lang:c++}, implemented-in::c, interface::commandline, role::program, scope::utility, suite::gnu, works-with::software:source
Section: devel
Priority: optional
Filename: pool/main/b/bison/bison_2.5.dfsg-2.1_i386.deb
Size: 671436
MD5sum: 1fba12a7c139faf813da27ced3db1001
SHA1: 320b34fe25decbd5cb7f8a575e4134619dd9125b
SHA256: b6ddb1811972043e7b8a90069b7e1d47c726b2e73e49aacbc434eb80f76dc057

Let’s try to install this buggy package!

fixed@gauss:~$ sudo apt-get install bison
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following extra packages will be installed:
  libbison-dev
Suggested packages:
  bison-doc
The following NEW packages will be installed:
  bison libbison-dev
0 upgraded, 2 newly installed, 0 to remove and 0 not upgraded.
Need to get 961 kB of archives.
After this operation, 2,201 kB of additional disk space will be used.
Do you want to continue [Y/n]?
Get:1 http://ftp.it.debian.org/debian/ sid/main libbison-dev i386 1:2.5.dfsg-2.1 [289 kB]
Get:2 http://ftp.it.debian.org/debian/ sid/main bison i386 1:2.5.dfsg-2.1 [671 kB]
Fetched 961 kB in 3s (312 kB/s)
Retrieving bug reports... Done
Parsing Found/Fixed information... Done
serious bugs of bison (-> 1:2.5.dfsg-2.1) <unfixed>
 #643446 - nip2: FTBFS: parse.c:1599:5: error: format not a string literal and no format arguments [-Werror=format-security]
   Merged with: 648765
Summary:
 bison(1 bug)
Are you sure you want to install/upgrade the above packages? [Y/n/?/...]

And now it’s my choose if install it or not (hint, use the “?” char to see the possible options).

Obviously we can also list the bugs of a certain package before trying to install it:

fixed@gauss:~$ apt-listbugs list bison
Retrieving bug reports... Done
Parsing Found/Fixed information... Done
serious bugs of bison (-> ) <unfixed>
 #643446 - nip2: FTBFS: parse.c:1599:5: error: format not a string literal and no format arguments [-Werror=format-security]
   Merged with: 648765
Summary:
 bison(1 bug)

And that’s all. Remember that apt-listbugs enters also when you give an apt-get dist-upgrade, preventing you to smash all your OS (although not so common in Debian…)

Just another link: http://raphaelhertzog.com/2010/12/20/5-reasons-why-debian-unstable-does-not-deserve-its-name/

 

 

Emacs e org-mode

E’ da un po’ che mi sono innamorato di org-mode, un modulo di Emacs (incluso nel branch stabile di Emacs fin dalla 20.0, mi pare…) che è perfetto per le mie manie/ossessioni/paranoie organizzatrici.

In breve, permette di avere varie liste, tra cose da fare, TODO, task semplici, ecc..Permette anche di fissare delle deadline o schedulare le attività, integrandosi nell’agenda di Emacs e producendo degli ottimi rapporti. E la cosa migliore è che tutti i files sono in testo puro, plain text, quindi leggibili anche senza emacs, da altri programmi o direttamente. La sintassi è davvero semplice.

Certo, si tratta di decidere secondo quale logica organizzare i propri impegni e le proprie liste (ad esempio scegliendo un approccio GTD), ecco i file che uso:

  • work.org
  • work.org_archive
  • personal.org
  • personal.org_archive

I file “archive” sono automaticamente creati da emacs nel momento in cui un oggetto (qualsiasi tipo) viene archiviato. Nel file work.org ovviamente ci sono informazioni di lavoro, nel personal.org tutto il resto. Un piccolo esempio:

#+STARTUP: overview

* DAILY TODOS [2/3]
 + [X] Mandare sms prove
 + [X] Chiamare g.
 + [ ] Chedere permesso mercoledì
* Casa
** Attività informatica
#+CATEGORY: INFORMATICA
*** Gauss
**** TODO Installare Debian LXDE su gauss
*** Erdos
**** TODO Cambiare batteria
*** Turing
**** TODO Cambiare HD con SSD
*** TODO Finire config-o-matic
  + Refactoring
  + Setup.py
  + Aggiungere routine installazione pacchetti

*** TODO Scegliere UPS
Dovrebbe avere supporto per autoshutdown/snmp/via LAN

*** TODO Batteria iPod
*** TODO org-mode android
*** TODO Scrivere post blog org-mode

** HIFI
#+CATEGORY: HIFI
*** TODO nuova puntina
*** TODO cavi casse
*** TODO pulire contatti
*** TODO pulire ampli
*** TODO lavare dischi

** Macchina
*** DONE Olio freni
    CLOSED: [2011-11-03 Thu 19:43]
*** TODO Bollo moto
    DEADLINE: <2011-11-17 Thu>

*** TODO Inserzione pezzi moto
** Altro
#+CATEGORY: ALTRO
*** TODO Vendere Korg
*** TODO Vendere Fishman pu+preamp
*** TODO Tenda
*** TODO Affilare Jagger

Il #+STARTUP: overview all’inizio serve a far visualizzare ad emacs, alla prima apertura, soltanto gli header principali (quelli con un solo asterisco). Possono essere espansi spostandocisi sopra e premendo TAB (una o più volte, a seconda di quanti sottolivelli vogliono essere espansi). Per espandere tutti quelli del file si può usare Shift+TAB.

I vari livelli sono ovviamente delimitati da diversi numeri di asterischi, sotto ogni livello si può inserire del testo libero o delle note.
A mio avviso una caratteristica importante sono le checkbox che si possono creare ovunque usando la sintassi: SPAZIO + SPAZIO [ SPAZIO ] SPAZIO (si fa prima a vederle nell’esempio precedente). Una volta creata una checkbox si può cambiare il suo stato ponendosi sopra e usando C-c C-c.
In questo modo è abbastanza inutile, ma se si mette nell’header superiore [/] oppure [%] (o tutti e due), questi si trasformeranno automaticamente in contatori, aggiornandosi ogni volta che selezioniamo o deselezioniamo una checkbox.
Per aggiornare tutti i contatori in un file si può usare la sintassi C-u C-c #

Alcuni elementi sono preceduti dalla parola TODO. Questa viene automaticamente riconosciuta da org-mode che agisce di conseguenza:

  • Viene evidenziata con colore diverso, a significare che è divenuto un elemento “attivo” e non solo testo.
  • Viene listato nell’agenda (vediamo dopo, anticipo solo che si può chiamare con C-c a t)
  • Può essere “ciclato” mettendocisi sopra e premendo C-c freccia-destra o C-c freccia-sinistra, e cambierà lo stato a seconda degli stati in una lista definiti dall’utente all’inzio del file, o nel .emacs
    Se nessuno stato “personalizzato” viene definito, esso ciclerà attraverso in questo modo:
    TODO -> DONE

Possiamo inserire delle schedulazioni o delle deadline per ogni header (quindi ogni cosa che inizia con uno o più asterischi), ponendoci sopra esso e usando la sequenza C-c C-s per lo scheduling (“Penso di dover iniziare a fare questa cosa il…”) o C-c C-d per la deadline (“Questa cosa deve essere completata entro il…”). In entrambi i casi si apre il calendario di Emacs in un frame separato che ci consente di scegliere il giorno. Ci si muove all’interno del calendario premendo il tasto Shift e le frecce, oppure inserendo manualmente la data.
Premendo invio ci comparirà, ben indentato sotto l’header che abbiamo scelto, la voce “SCHEDULED” o “DEADLINE” seguita dalla data.
Ovviamente nulla vieta di mettere schedule/deadline diversi su headers annidati…come nell’immagine qui sotto:

La cosa bella di org-mode è che tutto quanto è un file di testo, quindi possiamo tranquillamente scrivere, cancellare, modificare a mano i tag che ho elencato fin’ora (TODO, SCHEDULED, ecc..), le date e tutto il resto, ed Emacs le riconoscerà come “parole” speciali.
Se ad esempio voglio modificare una schedulazione posso riposizionarmi sull’header che mi interessa e premere ancora C-c C-s oppure modificare “a mano” la riga con la data; idem per cancellare un elemento…

Tuttavia tutte queste opzioni sono decisamente inutili se non sfruttiamo la possibilità di org-mode di interfacciarsi con l’agenda di Emacs (sapevate che Emacs ha un’agenda?) o di generare la sua.

Una volta che abbiamo creato il nostro bravo file, con le sue voci, i suoi header e le schedulazioni, possiamo avviare l’agenda con C-c a:

Ci viene presentato un menu di scelta, premiamo per iniziare a per vedere l’agenda per la settimana corrente:

Emacs ci genera automaticamente un file “di riepilogo” con le scadenze su cui stiamo lavorando. Spostandoci su una data e premendo Enter si “salta” all’header corrispondente. Come vedete le schedulazioni sono in verde mentre le deadline vengono visualizzate in rosso con il numero di giorni rimanenti (-x se sono scadute).
Possiamo uscire dalla “vista agenda” premendo q.

Sentitevi liberi di esplorare altre modalità di visualizzazione dei task, come quella che elenca solo i TODO (C-c a t) o la timeline completa (C-c a L). Il menu che compare premendo C-c a le elenca tutte.

Tutto questo è molto buono quando si lavora con un file solo, ma come ho detto prima io ho diviso i miei impegni in files differenti, uno personale, uno per il lavoro, ecc…
Dato che la visualizzazione di Emacs è unica (o perlomeno, io l’ho impostata così in modo da avere sempre sotto mano tutti gli impegni) serve qualcosa che divida graficamente le varie voci nell’agenda.
Per questo esistono le categorie e i tag.

I tag sono i più semplici da mettere: hanno come sintassi :tagname:altroeventualetag:ecc…: e come al solito possono essere inseriti sia manualmente sia automaticamente all’interno di emacs posizionandosi sull’header da “taggare” e premendo C-c C-c

Ovviamente org-mode indenterà tutti i tag appartenenti allo stesso header allo stesso livello.
A questo punto andiamo a ridiitare C-c a a per visualizzare l’agenda:

Grazie ai tag possiamo differenziare le varie voci (e non solo, i tag permettono di fare una marea di altre cose, come raggruppare le cose da fare, ma per questo rimando volentieri all’apposita sezione del manuale online).

Altro strumento utile sono le categorie. Per certi versi simili ai tag, si differenziano da questi perchè sono definite a livello di header e coinvolgono tutti i dati contenuti in essi (compresi eventuali altri sottoheaders). Volendo possono essere definiti a livello di file in modo che ogni elemento in quel determinato file abbia come categoria associata quella definita all’inizio del file con questa sintassi: #+CATEGORY: NOMECATEGORIA.
Anche per questo rimando al manuale online.

Una cosa che ho imparato, e di cui non posso più fare a meno, è la possibilità di inserire “al volo” dei dati (ad esempio dei TODO) all’interno di un file org e riprendere subito il proprio lavoro. Ad esempio, se sto lavorando su di un programma e mi viene in mente “Devo ricordarmi di inserire questa funzione all’interno di quell’altro programma” oppure “devo pagare il bollo della macchina” è molto comodo, con una rapida sequenza di tasti inserire l’idea al posto giusto, nel file giusto (o anche in un file temporaneo e poi spostare le idee quando si ha tempo) senza distrarsi troppo.

In org-mode questo si chiama capture ed è, come al solito, altamente personalizzabile. Io ad esempio ho inserito (tra l’altro) queste righe all’interno del mio file .emacs:

(global-set-key (kbd "C-M-r") 'org-capture)
(global-set-key (kbd "C-c r") 'org-capture)
(setq org-capture-templates
      (quote (("s" "work sysadm" entry (file+headline "~/notes/work.org" "SYSADM")
               "* TODO %?\n%U\n  %i\n")
              ("t" "daily todo" checkitem (file+headline "~/notes/personal.org" "DAILY TODOS")
               "+ [ ] %?\n%i \n")
              ("d" "da scaricare" entry (file+headline "~/notes/personal.org" "Scaricare/comprare")
               "* TODO %?\n %i\n %x\n")
              ("w" "Watching" entry (file+headline "~/notes/desiderata.org" "Watching")
               "* %?\n %i\n %x\n")
              ("r" "Reading" entry (file+headline "~/notes/desiderata.org" "Reading")
               "* %?\n %i\n %x\n")
              ("w" "Listening" entry (file+headline "~/notes/desiderata.org" "Listening")
               "* %?\n %i\n %x\n")
              ("e" "Learning" entry (file+headline "~/notes/desiderata.org" "Learning")
               "* %?\n %i\n %x\n")
              ("p" "Projects" entry (file+headline "~/notes/desiderata.org" "Projects")
               "* %?\n %i\n %x\n"))))
 

La cosa più interessante sono i templates. Prendiamo ad esempio

("w" "Listening" entry (file+headline "~/Dropbox/notes/desiderata.org" "Listening")
               "* %?\n %i\n %x\n")

Il primo elemento “w” indica il tasto da premere dopo aver immesso al sequenza C-c r (collegata al “capture-mode”), “Listening” è una descrizione che mi aiuta a ricordare cosa vuol dire quella entry, entry vuol dire che l’elemento che andrò ad inserire è una semplice entry (ma potrebbe essere una checkbox, una tabella, ecc), file+headline “~/notes/desiderata.org “Listening” vuol dire che questa entry va inserita all’interno del file ~/notes/desiderata.org alla sezione Listening.
La seconda riga descrive la sintassi della entry che sarà inserita. Rimando alla lista completa delle variabili che si possono inserire, sappiate che in quel modo quando inserisco la entry, oltre al testo viene inserita anche il contenuto della regione attiva (%i), il contenuto della cliboard (%x). La variabile %? invece controlla dove è posizionato il cursore.
Può sembrare molto complicato ma vi assicuro che non lo è affatto.

Se io sto lavorando ad esempio su di un file e mi viene in mente “Voglio ascoltare questo gruppo”, premo C-c r w (dopo la pressione di C-c r mi si presenta un menu da cui scegliere se non ricordo i tasti), inserisco quello a cui pensavo, premo C-c e ricomincio a lavorare.

Se invece voglio aggiungere una cosa da fare al volo, entro oggi, premo C-c r d (corrispondente a daily todo) e automaticamente nel file giusto viene creata una checkbox in cui inserire il testo. Chiudo e salvo con C-c C-c.

Questo ovviamente funziona in qualsiasi momento Emacs sia aperto…

In ultimo, aggiungo la mia configurazione del file .emacs:

(add-to-list 'auto-mode-alist '("\\.org\\'" . org-mode))
(setq org-log-done 'time)
(add-hook 'org-mode-hook 'turn-on-font-lock) ; not needed when global-font-lock-mode is on                                                                                                                                                   
(global-set-key "\C-cl" 'org-store-link)
(global-set-key "\C-ca" 'org-agenda)
(global-set-key "\C-cb" 'org-iswitchb)

(setq org-agenda-files '("~/notes/personal.org" "~/notes/work.org"))

(setq org-default-notes-file "~/notes/personal.org")
;; I use C-M-r to start capture mode                                                                                                                                                                                                         
(global-set-key (kbd "C-M-r") 'org-capture)
;; I use C-c r to start capture mode when using SSH from my Android phone                                                                                                                                                                    
(global-set-key (kbd "C-c r") 'org-capture)
;; Capture templates                                                                                                                                                                                                                         
(setq org-capture-templates
      (quote (("s" "sysadm" entry (file+headline "~/notes/work.org" "SYSADM")
               "* TODO %?\n%U\n  %i\n")
              ("t" "daily todo" checkitem (file+headline "~/notes/personal.org" "DAILY TODOS")
               "+ [ ] %?\n%i \n")
              ("d" "da scaricare" entry (file+headline "~/notes/personal.org" "Scaricare/comprare")
               "* TODO %?\n %i\n %x\n")
              ("w" "Watching" entry (file+headline "~/notes/desiderata.org" "Watching")
               "* %?\n %i\n %x\n")
              ("r" "Reading" entry (file+headline "~/notes/desiderata.org" "Reading")
               "* %?\n %i\n %x\n")
              ("w" "Listening" entry (file+headline "~/notes/desiderata.org" "Listening")
               "* %?\n %i\n %x\n")
              ("e" "Learning" entry (file+headline "~/notes/desiderata.org" "Learning")
               "* %?\n %i\n %x\n")
              ("p" "Projects" entry (file+headline "~/notes/desiderata.org" "Projects")
               "* %?\n %i\n %x\n"))))

E davvero infine alcuni link:

Two factor authentication con Google Authenticator

Nello scorso post ho parlato di mOTP per usare PAM (con l’esempio di SSH) usando un token hardware (nello specifico, un cellulare con Android).

Oggi invece ho scoperto un progetto di Google che farà felice la mia paranoia per la sicurezza casalinga, ovvero Google Two-Factor authentication.

Questo progetto in pratica si propone di usare una unlteriore autenticazione, oltre alla tradizionale password, per tutte le applicazioni Google (con qualche difficoltà per alcuni servizi, come Google Talk usando il protocollo Jabber e simili). Basta usare un generatore di token sincronizzato con Google ed il gioco è fatto. Inutile dire che il generatore è disponibile nell’Android Market (e su altre piattaforme).

La cosa bella è che tutto il progetto è stato rilasciato come open, compreso il modulo di autenticazione lato server (che sfrutta PAM) e che può quindi essere integrato in Linux nei modi più disparati (per una infarinatura su cosa sia PAM e come si usa e tutte le cose eccezionali che ci si possono fare vedere qui).

Il mio primo pensiero è quindi stato: “Posso davvero integrare questo modulo PAM con il pc di casa, per poter fare login da remoto o con chiave pubblica (cosa che già faccio) o con un token generato dal mio cellulare?”

Ecco come fare.

Sulla mia Debian Squeeze che funge da frontend per le connessioni SSH ho scaricato il pacchetto deb libpam-google-authenticator dal repository ufficiale (sid) di debian e l’ho installato. Le dipendenze sono solo libqrencode3.

Ora installiamo l’applicazione Google Authenticator sul nostro cellulare (credo esistano anche delle versioni Desktop) e teniamolo pronto per scattare.

Ora, dal PC dove abbiamo installato libpam-google-authenticator modifichiamo il file /etc/pam.d/sshd per applicare le regole soltanto alle connessioni SSH in entrata (a meno che non desideriate farlo su ogni tipo di autenticazione, in quel caso vi rimando al precedente link su PAM).

Commentiamo la riga

@include common-auth

E aggiungiamo all’inizio del file:

auth  sufficient    pam_google_authenticator.so

Il che praticamente significa che si può usare o Google Authenticator oppure il login standard (che dopo disabiliteremo) per accedere a questo computer via SSH con ogni utente.

INUTILE DIRE CHE PRIMA DI FARE QUALSIASI CAMBIAMENTO ASSICURIAMOCI DI AVERE UNA SHELL APERTA SUL PC IN QUESTIONE, MAGARI COME ROOT, IN MODO DA NON RIMANER “TAGLIATI FUORI” IN CASO DI PROBLEMI.

Modifichiamo anche /etc/ssh/sshd_config per cambiare la riga

ChallengeResponseAuthentication no

in

ChallengeResponseAuthentication yes

e facciamo ripartire il demone ssh con /etc/init.d/ssh restart

Ora, usando l’utente che dovrà autenticarsi sul sistema, posizioniamoci nella home e lanciamo il comando: google-authenticator. Ci si presenterà una schermata come questa:

A cui dovremo fare la foto con il nostro fedele Google Authenticator su Android. E ovviamente appuntarci da qualche parte tutti i codici che ci vengono proposti. Ma in un posto sicuro.

Rispondiamo quindi alle domande che il programma ci pone, tanto sono semplici e molto chiare, si può rispondere “y” a tutte.

A questo punto il nostro sistema è pronto: provando ad entrare con il nostro utente ci si presenterà dapprima il prompt classico per inserire la password. Dando invio a vuoto (che il sistema PAM non interpreterà come un “fallimento), dato che abbiamo dato l’opzione nullok) avremo di fronte un altro prompt che ci chiede di inserire un “Verification code”. Ovviamente inseriamo quello che ci propone il telefono, e saremo dentro.

Se invece non vogliamo/non abbiamo il telefono sottomano, basterà inserire la password al primo prompt per loggarci comunque (magie di “sufficient”).

Ovviamente si può rendere la cosa ancora più sicura usando un meccanismo di autenticazione a chiave pubblica per SSH; in questo caso se avremo la chiave privata corrispondente alla pubblica salvata sul server potremo entrare (anche facendo scadere la password dell’utente). Altrimenti ci verrà comunque richiesto il token.

 

PS. Se avete la vostra home cifrata (ad esempio con eCryptFS) date un’occhiata alla fine di questo file per sapere come fare per usare comunque libpam-google-authenticator.

 

Using MobileOTP in Debian (with SSH)

Intro

I ever liked the two-factor authentication systems, as described in an old post about pamusb, and similar.

Now I’ve tried to understand the lack of auth systems on linux based on the hardware one-time password generator (just to understand: they are the small devices you use to connect to the web portal of you bank).

Giving a look around seems that MOTP (Mobile One Time Password) is the simplest one for the following reasons:

  • Is open source. Fully.
  • It runs on Linux as well on Solaris and (I think) all other POSIX systems.
  • It have a lot of clients around, for my Android device, for iPhone, web pages and so on.
  • It can be integrated either with a RADIUS server or simply using PAM.

I don’t know it’s exact level of security (especially if the random seed is not adequately protected) but at the moment it works and it’s funny!

So, let’s try to install it:

Download

First of all you have to download:

  1. The MOTP script to check the password (useful to check before applying changes)
  2. The PAM module (to be compiled)
  3. The client. I use this, for Android.

Compile the PAM module

These are the dependencies to compile the PAM module: libpam0g-dev. You can install it using aptitude.

  1. Unpack the pam_mobile_otp-0.6.1.tgz
  2. Enter the directory and give the
    make

    command

  3. An executable file, called pam_mobile_otp.so together with another one, motp-manager should be created. The first one is the actual PAM module, mopt-manager is an helper to edit the configuration file (but best to hand edit it).

Install the PAM module

WARNING: THESE INFORMATION CAN CAUSE DAMAGE TO YOUR AUTHENTICATION SYSTEM. IF SOMETHING GOES WRONG YOU COULDN’T BE ABLE TO LOGIN ANYMORE, SO KEEP ALWAYS A SHELL OPENED (BEST AS ROOT) ON YOUR COMPUTER UNTIL YOU HAVEN’T TEST IT EXTENSIVELY.

  1. Copy the mopt.conf file into /etc/security/
  2. Copy the pam_mobile_otp.so into /lib/security/
  3. Create the /var/cache/motp/
  4. Edit the /etc/security/mopt.conf file choosing:
    1. An username (must be the username you use to logon into your computer). If you use the “root” user too via ssh, you have to add another line to the file changing the first field to “root”.
    2. A secret key (also called seed). Must be an hexadecimal 20 char password, like 02e5c2f981aa2c893b0b. This must be put also into your client.
    3. A 4 digit pin.
    4. The timezone. “0″ means the GMT timezone. For me, eg, is 2
  5. Delete the standard entry (test    1234567890abcdef        1234    0).
  6. Remember that each user not listed in this file but is present on the system will not be able to access using ssh.
  7. Edit the /etc/pam.d/sshdcommenting out
    @include common-auth

    And adding these lines:

    auth  sufficient /lib/security/pam_mobile_otp.so not_set_pass
    password required /lib/security/pam_mobile_otp.so debug
    account required /lib/security/pam_mobile_otp.so
  8. Restart the ssh server

Install the application on Android

You can install Mobile-OTP.apk by opening it with a file manager such as Astro or similar. You have to enable the third-party application flag in Settings -> Applications -> Unknown sources

There you must set the secret key and the pin.

Final check and test

First we have to check that the time set on both PDA and PC are much similar as possible. On the linux box type

date +%s

and then on the mOTP application on the phone (menu -> Time).

Now we can try to connect via SSH with the linux box. Note that an opened shell is safe in case you cannota access.

If you can’t enter try to modify the timezone field in /etc/security/motp.conf setting to 0.

Links

Official website: there are a lot of useful options, scripts and examples at http://motp.sourceforge.net/

Two client when you don’t have your PDA (but you have the key): one and two.

.screenrc!

In these days I’m customizing for the first time my GNU Screen (which in the past was incredibly underrated). So, here’s my ~/.screenrc file, with some comments.

startup_message off		# Disable the copyright page
altscreen on			# Clean the screen after editor exits
termcapinfo xterm* ti@:te@	# enable SHIFT-PGUP / SHIFT-PGDOWN scroll
defscrollback 30000		# Self-explain
term xterm    			# Useful to avoid strange key behaviour in
     				# Emacs
setenv LC_CTYPE en_US.UTF-8	# Env var
defutf8 on			# Env var
setenv DISPLAY ':0'		# Env var
nonblock on    			# Tell  screen  how to deal with user
	 			# interfaces (displays) that cease to accept output
vbell off			# Disable visual bell
msgwait 10			# Defines the time a message is displayed if screen
				# is not disturbed by other activity
# Startup sessions
screen    -t shell	1
screen    -t shell 	2
screen    -t shell	3
screen    -t log	4 tail -f /var/log/messages
screen	  -t top	5 top
select 1			# Select the first session at startup
# Some bind keys
bind = resize =
bind + resize +1
bind - resize -1
bind _ resize max
bind c screen 1			# Window numbering starts at 1, not 0.
bind 0 select 5
bindkey "^[Od" prev		# change window with ctrl-left
bindkey "^[Oc" next  		# change window with ctrl-right
# Backticks are small programs
# which output appears in the hardstatus bar
backtick 1 10 10 $HOME/bin/get_uptime
backtick 2 10 10 $HOME/bin/get_cputemp
backtick 3 10 10 $HOME/bin/get_freemem
backtick 4 10 10 $HOME/bin/get_freeswap
backtick 5 10 10 $HOME/bin/get_volume Master
backtick 6 10 10 $HOME/bin/get_gmail
# Settings for hardstatus bar
hardstatus alwayslastline '%{= M} %H%{= G} %l %= %{= w}%-w%{+b g}%n*%t%{w}%+w%{-b d} %= | %{G}%1`%{-} | %2` | %{c}mem/swap %3`/%4`%{-} | Vol. %5` | GMail: %?%{+b R}%6`%{-b d}%:%{G}none%{d}%? | %{c}%d %D %{B}%c '
caption always '%{= wk} %200` %= %100` %='
sorendition kw 	    	      	 # Change  the  way  screen does highlighting
	    			 # for text marking and printing messages
hardcopydir ~/.screen		 # Defines a directory where hardcopy files will be placed

~/bin/get_uptime

#!/bin/bash
uptime | awk '{print $2,$3,$4,$5}'

~/bin/get_cputemp

#!/bin/bash
sensors | grep temp1 | head -1 | awk '{print $2}' | tr -d + | tr ° ' '

~/bin/get_freemem

#!/bin/bash
free -m | grep - | awk '{print $4}'

~/bin/get_freeswap

#!/bin/bash
free -m | grep Swap | awk '{print $4}'

~/bin/get_volume

#!/bin/bash
status=$(amixer sget $1 | tail -n 1)
vol=$(echo ${status} | gawk '{print $5}' | tr -d [%])
state=$(echo ${status} | gawk '{print $7}')
text="${vol}"
echo ${text}

~/bin/get_gmail

#!/bin/bash
gmail_login="yourlogin"
gmail_password="*********"

received="$(wget --secure-protocol=TLSv1 --timeout=3 -t 1 -q -O - https://${gmail_login}:${gmail_password}@mail.google.com/mail/feed/atom \
--no-check-certificate | grep 'fullcount' | sed -e 's/.*//;s/.*//' 2>/dev/null)"

if [ "$received" != 0 ]; then
    echo "$received"
fi

Backticks are really neat, here’s how my terminal appears now: