Two-Factor authentication adds an extra layer of security to the authentication process to prevent unauthorized users to access your services or data.
Normally you only type username and password (something you know) but with Two-Factor authentications, additionally you need to provide something you have (mobile phone running Android, iOS or Blackberry with one time codes when using Google Authenticator).
Google Authenticator on iPhone1.
sudo apt install libqrencode3
wget http://ftp.us.debian.org/debian/pool/main/g/google-authenticator/libpam-google-authenticator_20110413.68230188bdc7-1.1_amd64.deb
TODO: Update URL for Ubuntu, instead of Debian.
dpkg -i libpam-google-authenticator_20110413.68230188bdc7-1.1_amd64.deb
This has to be done for each account that should be able to login with Two-Factor Authentication.
google-authenticator
Scan the QR code with your phone in the Google Authenticator app and answer yes to all questions unless you want some specific options.
Locate a line in the file starting with ChallengeResponseAuthentication and change the value to yes.
...
ChallengeResponseAuthentication yes
...
/etc/init.d/ssh restart
Next time you login to SSH you will be prompted for a Verification code in addition to the standard login and password.
This is where you use the code shown on your mobile device.