Reply
Thread Tools
Posts: 1,289 | Thanked: 4,316 times | Joined on Oct 2014
#1
I added two-factor authentication on my Jolla, to require username/token/password for connecting thru SSH to the device.

Since I was asked how I did this, I post this instruction page

Firstly, I compiled the 'pam-google-authenticator' code from github to be able to use the pam_google_authenticator.so library to accomplish this. The resulting library, and google-athenticator binary (to generate the secret key on device). It is published on my merproject page, so you will need to add this repository.

As you can guess from above, PAM is used for authenticating this way, so a few changes to sshd_config and pam files are needed (described below).

Now, the instructions, they are quite straight-forward, so I dont think they will cause much confusion

First, on device:

become root:
Code:
[nemo@Jolla ~]$ devel-su
Add my repository:
Code:
[nemo@Jolla ~]# ssu ar nieldk http://repo.merproject.org/obs/home:/nielnielsen/sailfish_latest_armv7hl/
[nemo@Jolla ~]# pkcon refresh
Install google-authenticator and PAM libs
Code:
[nemo@Jolla ~]# pkcon install pam-google-authenticator
Create Google Authenticator, secret keys for user nemo
Code:
[nemo@Jolla ~]# exit
[nemo@Jolla ~]$ google-authenticator
Follow on-screen-instructions:

Do you want authentication tokens to be time-based (y/n) y
https://www.google.com/chart?chs=200...%26issuer%3Dxx
Your new secret key is: 2C3IHASRPY3PHHGAAF5
Your verification code is 312471
Your emergency scratch codes are:
12345670
12345671
12345672
12345673
12345674

Do you want me to update your "/home/nemo/.google_authenticator" file (y/n) y

Do you want to disallow multiple uses of the same authentication
token? This restricts you to one login about every 30s, but it increases
your chances to notice or even prevent man-in-the-middle attacks (y/n) Do you want to disallow multiple uses of the same authentication
token? This restricts you to one login about every 30s, but it increases
your chances to notice or even prevent man-in-the-middle attacks (y/n) y

By default, tokens are good for 30 seconds and in order to compensate for
possible time-skew between the client and the server, we allow an extra
token before and after the current time. If you experience problems with poor
time synchronization, you can increase the window from its default
size of 1:30min to about 4min. Do you want to do so (y/n) n

If the computer that you are logging into isn't hardened against brute-force
login attempts, you can enable rate-limiting for the authentication module.
By default, this limits attackers to no more than 3 login attempts every 30s.
Do you want to enable rate-limiting (y/n) y


Take a note of the secret key 2C3IHASRPY3PHHGAAF5
This is what you need to enter in the Google Authenticator application of your choise

Now, change the configuration files for sshd
become root:
Code:
[nemo@Jolla ~]$ devel-su
[nemo@Jolla ~]# nano /etc/ssh/sshd_config
add (or change) lines:
ChallengeResponseAuthentication yes
UsePAM yes


Code:
[nemo@Jolla ~]# nano /etc/pam.d/sshd
add (or change) lines:
auth required /usr/lib/security/pam_google_authenticator.so

To test connection with two-factor authentication, restart sshd and terminate connection:
Code:
[nemo@Jolla ~]# pkill sshd
(will exit you current SSH connection)

Now, on laptop:

Code:
nieldk@nn:~$ ssh nemo@your.phone.ip.adress
Anser login questions

Verification code: <Google Authenticator code>
Password: <password>

Last login: Sun Apr 26 14:01:11 2015 from x.x.x.x
,---
| SailfishOS 1.1.4.28 (Äijänpäivänjärvi) (armv7hl)
'---
[nemo@Jolla ~]$


Done!

Last edited by nieldk; 2018-05-08 at 09:08.
 

The Following 7 Users Say Thank You to nieldk For This Useful Post:
peterleinchen's Avatar
Posts: 4,117 | Thanked: 8,901 times | Joined on Aug 2010 @ Ruhrgebiet, Germany
#2
Reads straight-forward.
Just missed another devel-su before nano /etc/ssh/sshd_config
__________________
SIM-Switcher, automated SIM switching with a Double (Dual) SIM adapter
--
Thank you all for voting me into the Community Council 2014-2016!

Please consider your membership / supporting Maemo e.V. and help to spread this by following/copying this link to your TMO signature:
[MC eV] Maemo Community eV membership application, http://talk.maemo.org/showthread.php?t=94257

editsignature, http://talk.maemo.org/profile.php?do=editsignature
 

The Following User Says Thank You to peterleinchen For This Useful Post:
Posts: 1,289 | Thanked: 4,316 times | Joined on Oct 2014
#3
Originally Posted by peterleinchen View Post
Reads straight-forward.
Just missed another devel-su before nano /etc/ssh/sshd_config
Added. Thanks
 
Reply


 
Forum Jump


All times are GMT. The time now is 10:05.