This is a simple setup guide to enabling Two Factor Authentication (2FA) on Linux SSH login. I this article I wont go deep into setup and issues that I have faced when implementing this. First thing is first Update your system first. I have used Ubuntu 20.04 and it is always up to date. To enable 2FA you need to install google authenticator modules sudo apt install libpam-google-authenticator Configuration for PAM and SSHD Add the the following line to /etc/pam.d/sshd and After adding this line please restart the sshd services. auth required pam_google_authenticator.so Go to /etc/ssh/sshd_config and check if the following line exist. Default value will be "no" so change it to "yes" to activate. ChallengeResponseAuthentication yes Configuration for Authenticator In the terminal run google authenticator command It will ask few things to acknowledge by user. Details you can see from the below video. Once this part is done you are ready to use the 2FA in ubuntu. T...
If you want to run your own script for example a shell script, python etc as a Linux service, please follow this guide. I have tested and already using this methods and this works perfectly. In this example i am using an Ubuntu Linux and a shell script (which will run ngrok as service) if you want to know more about ngrok check out there website.
STEP#1: Prepare you script file that you want to run as a service.
once you are done with editing save and exit
STEP#2: Prepare the service
Go to "/etc/systemd/system" and create a file with your naming preferences but should end with a ".service" for example my file name was ngrok.service
This how the file should look like. ExecStart is where you define the script that you want to run. Once you done editing save the file and follow the commands as follows.
To enable the service
systemctl enable ngrok.service
Reload the deamon
systemctl daemon-reload
Test the service
if you run "service ngrok start" it will start the service and you can type "service ngrok status" to check if the service is running or not and you can top the service by "service ngrok stop" command.
if it is running it will show as above image.
I hope this tech tip will help you in doing your own projects. Please do not forget to subscribe or give a comment in case if you have any questions.
STEP#1: Prepare you script file that you want to run as a service.
once you are done with editing save and exit
STEP#2: Prepare the service
Go to "/etc/systemd/system" and create a file with your naming preferences but should end with a ".service" for example my file name was ngrok.service
This how the file should look like. ExecStart is where you define the script that you want to run. Once you done editing save the file and follow the commands as follows.
To enable the service
systemctl enable ngrok.service
Reload the deamon
systemctl daemon-reload
Test the service
if you run "service ngrok start" it will start the service and you can type "service ngrok status" to check if the service is running or not and you can top the service by "service ngrok stop" command.
if it is running it will show as above image.
I hope this tech tip will help you in doing your own projects. Please do not forget to subscribe or give a comment in case if you have any questions.
Comments