EK bio photo

EK

Totally not a hacker

Email Twitter Github

How to use One Time Password for SSH in Ubuntu Linux

Install deb pkgs

apt-get install -y libpam-otpw otpw-bin

Add OTPW pam modules in /etc/pam.d/sshd

#@include common-auth

#Enable OTPW Authentication
auth       required     pam_otpw.so
session    optional     pam_otpw.so

Check /etc/ssh/sshd_config

UsePrivilegeSeparation yes
ChallengeResponseAuthentication yes
UsePAM yes
PubkeyAuthentication yes
PasswordAuthentication no

Now you can restart sshd:
service ssh restart

After you can login to server only with ssh-key or otpw =)

Generate OTPW list for $USER

su - user
otpw-gen > otpw_list.txt 
enter prefix for password list
for ex 123

Login with OTPW to server

ssh user@remote_host
Password 126:
Welcome to Ubuntu 14.04.1 LTS (GNU/Linux 3.13.0-32-generic x86_64)

Find password in otpw_list and add your prefix to it, you will get 123LQQF uFOW
126 LQQF uFOW