This is a simple bash script that kind of works as a 2FA for SSH. The good thing about the script is that you can use it on shared hosting platforms where you do not have root/sudo access.
This has been tested on CentOS servers.
Be careful when setting your password so that you do not lock your self out
In order to set that it up just follow these steps here:
- Upload the file to your home folder
- Change the password in the script to the password that you would like to use
- Make the file executable (chmod +x 2fa.sh)
- To test the script just run it and check if you can authenticate as normal (Just run ./2fa) . If that works proceed to the next step
- Add the following line in your ~/.bashrc file (Note, update the path accordingly)
. /path/to/the/file/2fa.sh
Note! The dot before the /path/ is very important as that way you will be running the script in the same shell! Without the dot the script would not work
That is pretty much it, after that you will be prompted for a password after your actual SSH auth is completed.