مع زيادة الطرق التي يستخدمها المهاجمون في عمليات الاختراق التي يقومون بها، يحتاج مديرو الأنظمة إلى رفع مستوى الحماية الخاص بأنظمتهم. إحدى هذه الطرق هي المصادقة المزدوجة أو ما يعرف بـ Two-Factor Authentication.
ما هي المصادقة المزدوجة؟
كلمات المرور هي شيء يعرفه المستخدم (something you know). هناك العديد من الوسائل التي يتم من خلالها مهاجمة كلمات المرور. وكون كلمات المرور هي الحماية الأكثر استخداما والتي بمعرفتها (أو الحصول عليها) يمكن للمهاجم اختراق الأنظمة تعتبر إضافة شيء آخر إلى عملية المصادقه أمرا مهما من أجل جعل مهمة المهاجم أمرا اصعب الإضافة، هنا هي عبارة عن شيء في حوزة المستخدم (something you have) وهو في حالتنا هذه: الهاتف المحمول.
قامت جوجل في الفترة الأخيرة بجعل المصادقة المزدوجه متوفرة على نطاق واسع سواء على بريدها الإلكتروني وكذلك عبر توفير إضافات يمكن للمستخدمين تثبيتها على أنظمتهم لتسهيل تفعيل المصادقة المزدوجة.
هنا سنقوم إن شاء الله بتغطية طريقة تفعيل المصادقة المزدوجة على أنظمة أبنتو. ننصح مديري هذه الأنظمة بتفعيلها من أجل حماية أفضل لأنظمتهم، هذه الحماية لا تكلفك شيئا سوى وقت تثبيتها على أنظمتك.
الخطوات
تفعيل المصادقة المزدوجة
اذهب إلى لوحة إدارة نطاقك (أو ادارة بريدك في حال لم تكن تمتلك نطاقا) واختر (الأدوات المتقدمة) (Advanced Tools) ثم اختر “Allow users to turn on two-factor authentication” بعد ذلك اذهب إلى (حسابي) (My Account) واضغط على (استخدام المصادقة المزدوجة) (Using 2-step verification).
تثبيت مصادق جوجل (Google Authenticator) على ا/أبنتو
ملاحظة: الخطوات التالية تم تنفيذها على نظام أبنتو 10.04
١- قم بتحميل مكتبة libpam0g-dev والتي يحتاجها Google Authenticator
ملاحظة: لحظة كتابة هذا المقال كان اسم الملف هو libpam-google-authenticator-1.0-source.tar.bz2
٣- قم بتثبيت برنامج gcc
#apt-get install gcc
ملاحظة: وجود برنامج gcc على خادمك له تحذيرات أمنية لذلك قم بإزالته بعد الانتهاء من تثبيت Google Authenticator
٤- قم بفك ضغط البرنامج وتثبيته
$bunzip2 libpam-google-authenticator-1.0-source.tar.bz2
$tar xvf libpam-google-authenticator-1.0-source.tar
$cd libpam-google-authenticator-1.0-source
$sudo make install
٥- نقوم الآن بعمل ملف common-auth حتى يشمل إضافة Google Authenticator
vim /etc/pam.d/common-auth
وأضف السطر التالي
auth required pam_google_authenticator.soبحيث يصبح شكل الملف النهائي هو
# here are the per-package modules (the "Primary" block)
auth required pam_google_authenticator.so
auth [success=1 default=ignore] pam_unix.so nullok_secure
# here's the fallback if no module succeedsملاحظة: لا تقم بأي تعديل على الملف ما عدا إضافة سطر Google Authenticator قبل سطر pam_unix.so
٦- قم بتفعيل خاصية ChallengeResponseAuthentication في برنامج SSH حتى يصبح Google Authenticator جزءا منه.
# Change to yes to enable challenge-response passwords (beware issues with
# some PAM modules and threads)
ChallengeResponseAuthentication yes
# some PAM modules and threads)
ChallengeResponseAuthentication yes
ملاحظة: هنا قمت فقط بتغيير القيمة من no إلى yes
الآن نقوم بإعادة تشغيل خدمة SSH من أجل أن تصبح التغييرات التي قمنا بها مفعلة.
service ssh restart
لا تقم بالخروج من النظام ابدا في هذه المرحله والا فلن تتمكن من الدخول مرة اخرى
٧- لتفيعل Google Authenticator على حساب
bashar@s4a:~$ google-authenticator
Do you want authentication tokens to be time-based (y/n) y
https://www.google.com/chart?chs=200×200&chld=M|0&cht=qr&chl=otpauth://totp/bashar@s4a%3Fsecret%
Your new secret key is:
Your verification code is
Your emergency scratch codes are:
***55**
***22**
***77**
***22**
***11**
Do you want me to update your “/home/bashar/.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) 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) y
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
Do you want authentication tokens to be time-based (y/n) y
https://www.google.com/chart?chs=200×200&chld=M|0&cht=qr&chl=otpauth://totp/bashar@s4a%3Fsecret%
Your new secret key is:
Your verification code is
Your emergency scratch codes are:
***55**
***22**
***77**
***22**
***11**
Do you want me to update your “/home/bashar/.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) 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) y
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
٨- قم بنسخ العنوان أعلاه في متصفحك
https://www.google.com/chart?chs=200×200&chld=M|0&cht=qr&chl=otpauth://totp/bashar@s4a%3Fsecret%<USERS_KEY>
٩- قم بعملية مسح للكود الذي سيظهر (كود يعرف ب QR) من خلال تطبيق Google Authenticator على هاتفك المحمول.
التطبيق متوفر في أسواق هواتف أندرويد وآيفون وبلاك بيري باسم Google Authenticator وفي سوق هاتف ويندوز فون باسم Authenticator وهو إصدار غير رسمي بخلاف Google Authenticator المدعوم من قبل جوجل.
١٠- جرب من شاشة سطر أوامر أخرى الوصول إلى الخادم حتى تتأكد من أن المصادقة المزدوجة تعمل الآن.
$ssh bashar@s4a
Verification code:
Password:
Linux s4a 2.6.32-41-server #88-Ubuntu SMP Thu Mar 29 14:32:47 UTC 2012 x86_64 GNU/Linux
Ubuntu 10.04.4 LTS
bashar@s4a:~$كما تلاحظون هناك شيء جديد يسبق كلمة المرور وهو Verification Code والذي تحتاج إليه بالإضافة إلى كلمة المرور من أجل الوصول إلى خادمك عبر خدمة SSH.