Ubuntu SSH + TOTP
In order to protect your SSH against hacks, the most basic you can do is to change the port, but that is never enough. We know the basics to be disable root logins, change port, enable pubkey authentication, IP based blocking and so on. However, one shoe never fits all. If you keep changing computers, it is very difficult to setup pubkey authentication on all computers, specially if you are not using your personal computer to login.
That is where the TOTP comes in. You still have to carry around a mobile phone, but I think we all do now a days.
Install
Install google authenticator
1 | |
Enable
and enable it for SSH:
1 | |
Append to the bottom:
1 2 | |
And edit the ssh config file:
1 | |
to enable it in SSH config as well as change the SSH port
1 2 3 4 5 6 7 8 | |
Setup TOTP for user
Now prepare your phone with your favorite TOTP app, like google authenticator and run this command in shell:
1 | |
And answer as following:
1 2 3 4 5 6 7 8 9 10 | |
And then just restart ssh for the changes to take effect.
1 | |
Now use terminal on linux/mac or putty on windows to login. Do note that BitviseSSH does not work properly with this for some reason...